Should custom stores have embedded effects like this?
So lets have I have a custom store to manage updating a value and a debounce version (so that an expensive action can trigger on the debounce value) like this:
From a patterns standpoint, does it make sense to instead of having the consumer of this store have do this:
you allow them do something like this:
Does this come down to personal preference or are there bigger pros / cons between these two approaches (the benefit of the embedded is the the effect and creation of the store is in one place)?
1 Reply
i would do the following:
if you want to add it to the declaration i would probably do the following:
with a second options-object
a, now that i read the question a bit better: not including the listener is also a fair option
createSignal
also does not have an onUpdate
listener, for example
one suggestion tho: I would not call your primitive a store
. in solid a store
implies that it is fine-grained, like solid's createStore
, but your primitive is a signal instead.