-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up examples and tutorials as well as minor doc tweaks.
Also add a reconnect loop to collab clicker.
- Loading branch information
Showing
70 changed files
with
164 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
examples/coffeesearch/package.json → examples/coffee-vector-search/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
examples/ssr/solid-ssr-app/package.json → examples/collab-clicker-ssr/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "solid-ssr-app", | ||
"name": "collab-clicker-ssr", | ||
"private": true, | ||
"version": "0.0.1", | ||
"type": "module", | ||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { createSignal, onMount } from "solid-js" | ||
|
||
export type Clicked = { | ||
count: number | ||
}; | ||
|
||
declare global { | ||
interface Window { | ||
__INITIAL_DATA__: Clicked | null; | ||
} | ||
} | ||
|
||
export function App({ initialCount }: { initialCount?: number }) { | ||
const [count, setCount] = createSignal(initialCount ?? 0) | ||
|
||
const onClick = () => { | ||
setCount((count) => count + 1); | ||
|
||
fetch("/clicked").then(async (response) => { | ||
const clicked = (await response.json()) as Clicked; | ||
if (clicked.count > count()) { | ||
setCount(clicked.count); | ||
} | ||
}); | ||
}; | ||
|
||
onMount(async () => { | ||
const trailbase = await import("trailbase"); | ||
const sleep = (ms: number) => new Promise(r => setTimeout(r, ms)); | ||
|
||
const listen = async () => { | ||
const client = new trailbase.Client(window.location.origin); | ||
const api = client.records("counter"); | ||
|
||
const reader = (await api.subscribe(1)).getReader(); | ||
|
||
while (true) { | ||
const { done, value } = await reader.read(); | ||
if (done) { | ||
console.log("done"); | ||
break; | ||
} | ||
|
||
const update = value as { Update?: { value?: number } }; | ||
const updatedCount = update.Update?.value; | ||
if (updatedCount && updatedCount > count()) { | ||
setCount(updatedCount); | ||
} | ||
} | ||
}; | ||
|
||
// Re-connect loop. | ||
while (true) { | ||
await listen().catch(console.error) | ||
await sleep(5000); | ||
} | ||
}); | ||
|
||
return ( | ||
<div class="flex flex-col gap-4 text-neutral-800"> | ||
<h1>TrailBase Clicker</h1> | ||
|
||
<div class="px-4 py-2"> | ||
<button | ||
class="rounded bg-neutral-100 p-2 font-medium hover:scale-110 hover:outline outline-accent-600 active:scale-100 animate-all" | ||
onClick={onClick} | ||
> | ||
clicked {count()} times | ||
</button> | ||
</div> | ||
|
||
<p> | ||
Click the button across different tabs, windows or browsers. | ||
</p> | ||
</div> | ||
) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
read: fill | ||
pnpm run read | ||
|
||
fill: | ||
pnpm run fill | ||
|
||
clean: | ||
rm -rf traildepot/data | ||
|
||
.PHONY: clean read fill |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.