-
Hello, everyone. I have a potentially weird question. Hear me out. I have created a library for web workers. The usual is there:
But also a unique feature: Cancellation tokens that use Cancellation is easy to react to: The promise gets rejected. However, while building the demo site (in Svelte, obviously), I realized it would be nice if the work item's The question: In a zero-dependency library like the one I developed, what would be the best way to at least prepare the road of Svelte picking up changes on |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You could e.g. implement the Svelte readable store contract, which just needs a Other than that, you could just expose an event callback function like |
Beta Was this translation helpful? Give feedback.
It's a function that is called when the value of the store is changed, before all the subscribers are executed.
It exists to prevent invalid intermediate states particularly when using
derived
stores.Regular users are unlikely to need this, the argument should default to a
noop
.In Svelte it is used like this:
A bit more info on this in my answ…