Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with mounting a module that has updates on instantiation #65

Open
awei01 opened this issue May 21, 2018 · 2 comments
Open

Issue with mounting a module that has updates on instantiation #65

awei01 opened this issue May 21, 2018 · 2 comments

Comments

@awei01
Copy link

awei01 commented May 21, 2018

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.

@adamhaile
Copy link
Owner

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!

@awei01
Copy link
Author

awei01 commented May 21, 2018

Oh, ok. Good to know. Thanks for the fast response. Looking forward to the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants