replicache icon indicating copy to clipboard operation
replicache copied to clipboard

Svelte support

Open aboodman opened this issue 2 years ago • 1 comments

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.

aboodman avatar Jul 31 '22 02:07 aboodman

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

csenio avatar Aug 23 '23 09:08 csenio