SolidJSS
SolidJSโ€ข3y agoโ€ข
4 replies
zishh

Custom signal for observable props parameter - Reactivity issue

have library which contains objects with observable properties. To make this work with solid I want to create a custom signal which triggers the reactive functionality.

Basically something like this:
https://playground.solidjs.com/anonymous/749a49e0-da6f-465b-995a-947e7d6bbdf9

Changing the observable value (by clicking the "Update" button) works fine. But the observable itself can change also change (by clicking the "Reset" button) and because props.observable is not called in a tracked context, we lose reactivity i.e. updates no longer have a visible effect.

So I understand why this is happening but I do not know what the best way to solve this looks like. I thought about passing a function which returns the observable to createCustomSignal instead of the value itself. But I do not know what the implementation of createCustomSignal would then look like such that it can track changes.

Any ideas how to make this work?
Quickly discover what the solid compiler will generate from your JSX template
Was this page helpful?