-
Notifications
You must be signed in to change notification settings - Fork 24
Initialize Change Function #50
Comments
Quote from the readme:
You probably don't want the else clause, because that could be either an insert or update. In this case, if you want to check for insertion, it would be: if (previousValue == null) { ... } Is calling it the change function misleading? I wasn't too sure about the name, maybe it could be called the mapping function or something, it's only called change internally and in the docs. |
I apologize for the large amount of time that's passed since I said anything. To answer your question right away, I did not find the name of the I've written a test that shows the error more clearly: https://github.com/jakesower/simulacra/commit/8ad5faefa40392a0833e088b16eea73db477fcde It appears to be due to having a bound variable set to Please let me know if the test is invalid for some reason, otherwise I'll send you a PR that makes the test pass in the coming hours/days. |
I think the test case is mistaken here: https://github.com/jakesower/simulacra/commit/8ad5faefa40392a0833e088b16eea73db477fcde#diff-910eb6f57886ca16c136101fb1699231R202 Since the value of { simple: 'Simple', change: null }
{ simple: 'Simple', change: undefined }
{ simple: 'Simple' }
In the example on the homepage you can try: state.details = null and it will remove the entire element corresponding to the value. |
I've tried to do something decidedly unusual. The behavior isn't exactly what I expected, but it's logical. I can pass in some other value that means Thanks for your time! I'll just formulate my code differently to skirt the issue. |
That sounds perfectly fine to do actually. I will close this now. |
I would like to run a change function when my object is bound. Example:
The change function associated with
name
doesn't get run unless I actually changestate.name
. While it is a function calledchange
, it would be nice if it ran at init time.messages
is automatically inserted as expected at init.Is this a misguided approach, and if so, do you have any recommendations on how to get that function to run other than setting
state.name
after init time?Thank you.
The text was updated successfully, but these errors were encountered: