xnought / svelte-store-anywidget

Use svelte writable stores synced with anywidget (store updates on notebook change or svelte change)
4 stars 0 forks source link

consider just linking with existing svelte stores instead of creating a new one #2

Closed xnought closed 1 year ago

xnought commented 1 year ago

Instead of calling

register(model)
const count = anywritable("count")

Create the store beforehand and simply link with the view

const count = writable(0);
const dispose = linkanywidget(count, model, "count")

This way you can more easily define the svelte store beforehand in a separate file.

downside is less readable code if you're not familiar with svelte. The current method feels like a more concise syntax.

xnought commented 1 year ago

called it syncAnywidget