surplus
surplus copied to clipboard
Issue with mounting a module that has updates on instantiation
Hi, new to Surplus and enjoying it so far. I recently ran into this issue and have been left scratching my head. I've created a fiddle here: https://jsfiddle.net/awei01/hfLq5knr/
The basic scenario is that I have a module that updates some S
values when instantiated (like a loading indicator). Correct me if I'm wrong, but I'm assuming that the issue is that the component wraps everything in an S.freeze
or something, so that values that change throw the warning about values changing.
I'm wondering how to unfreeze
the instantiation so that the component can observe the loading state. Hopefully my demo will be clearer than this crappy explanation.
Woah! This is actually a bug in S.value(). If you change isLoading() to an S.data() it will work. It will also work if you add a trivial computation that reads isLoading() before you call doSomething(), because the bug is in an optimization for the case where a signal changes that isn't being read by anyone. Simplest repro is:
const v = S.value(1)
v(2) // ok
v(3) // error
I'll get a fix out for this soon. Thanks for the report, especially for including an example!
Oh, ok. Good to know. Thanks for the fast response. Looking forward to the fix.