Open aboodman opened 2 years ago
Svelte has a small pitfall when the scan function isn't pure. Need to manually clean those up in a reactive statement like this:
let unsub
$: {
unsub?.()
unsub = rep.subscribe(tx => tx.scan({prefix: `users/${currentTeam}`}).values().toArray())
}
onDestroy(unsub)
The best abstraction I found was making a renderless component out of it and then using it like this:
<Rep
prefix={`channels/${$activeTeam.id}`}
onData={(data) => {
// do whatever you want with the data
}}
/>
There is an issue for it but it's closed: https://github.com/sveltejs/svelte/issues/5283
Right now it is theoretically possible to use Replicache with svelte but not easy as there is no sample. It's also possible feature work is necessary to make it work well (for example, for Solid, we know that #1010 is required).
We should create a sample/quickstart for Svelte and make sure it works well.