Is it possible to untrack writes to a signal?

I have a certain use case, in which I have a function called getTextBoxValue which needs to run at a particular time. The way I control the execution of this function is by using a boolean signal called IsTriggerFieldChanged like a flag. So I set the value of this flag to be true, to execute my function. The problem is that within the function, I need to reset the value of the flag back to false for it to work a second time. However when I set the flag to false, it triggers a re-execution of my function (IsTriggerFieldChanged) which undoes the calculated value Input field which controls the function execution: https://pastebin.com/yhqyAUh9 The function that Im trying to run based on the flag: https://pastebin.com/PAxTtZ1Q
Pastebin
Input field which controls function execution - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin
function getTextBoxValue(field: Field): string | number | string[]...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
6 Replies
Jasmin
Jasmin10mo ago
There is a untrack function. Does this fit your usecase? https://www.solidjs.com/docs/latest/api#untrack
SolidJS
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.
TicTacMan
TicTacMan10mo ago
Yeah I was looking into that, but the docs state that untrack only untracks the reads and not writes. https://www.solidjs.com/tutorial/reactivity_untrack The problem for me is that since I set (write) the signal back to false in my function, it triggers a re-render
Jasmin
Jasmin10mo ago
ohh you're right thinkies I don't know of a way to "silently" update a signal
Otonashi
Otonashi10mo ago
there technically isn't one however in this case you'd normally not set a signal signalling a change, but have a signal containing the value of the field instead alternatively if you must, you could use the equals option on signals to do what you're trying to, e.g. const [IsTriggerFieldChanged, SetTriggerFieldChanged] = createSignal(false, { equals: (prev, next) => next === false }) or simply const [TrackTriggerFieldChanged, TriggerFieldChanged] = createSignal(undefined, { equals: false }) which wouldn't need resetting (call the setter with no args)
TicTacMan
TicTacMan10mo ago
Yeah Ideally I would have just created a signal for the value attribute of my input field, and in my function, directly manipulated that signal. However, my page is pretty dynamic and sometimes the page could have upwards of 100+ input fields (think of an accountancy sales order entry page). So I wanted to stay away from any solution in which each field has its own signal, because im not sure about the performance implications of having 100+ signals on my page This might actually work really well for my use case, ill give it a shot Just an update, works perfectly for my use case
Alex Lohr
Alex Lohr10mo ago
Signals are cheap, as long as they are not too many subscribed effects and computations.