#How to subscribe a signal using createEffect?

11 messages · Page 1 of 1 (latest)

tropic bloom
#

I have a code like this.
I want to change v2 value to 0 if v1 value get changed.
How to make this using createEffect?

#

How to subscribe signal?

#

How to subscribe a signal using createEffect?

stark flicker
#
createEffect(on(v1, () => {
setV2(0)
}))
#

You can use the on function to subscribe to certain signals
https://www.solidjs.com/docs/latest/api#on

Solid is a purely reactive library. It was designed from the ground up with a reactive core. It's influenced by reactive principles developed by previous libraries.

tropic bloom
stark flicker
#

That works too

tropic bloom
stark flicker
#

well that's why there is the on function to make it more explicit

tropic bloom
stark flicker
#

() => myStore.v1