6.1.1 behaviour change: no longer possible to reassign functions in observables #2760
Replies: 3 comments 13 replies
-
If you think you have found a bug, creating an issue is generally better than a discussion. Either way, can you provide runnable reproduction that we can inspect? |
Beta Was this translation helpful? Give feedback.
-
But yes the behaviour has been made explicit. So what you might be looking
for to have observable actions is: annotate the field with observable, and
wrap the value in action.
…On Thu, 28 Jan 2021, 20:03 Daniel K., ***@***.***> wrote:
If you think you have found a bug, creating an issue is generally better
than a discussion. Either way, can you provide runnable reproduction that
we can inspect?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2760 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBFUT6NP5ZB6IK5XQZ3S4G7J3ANCNFSM4WXRE4CA>
.
|
Beta Was this translation helpful? Give feedback.
-
Since mobx 6.0 all functions are auto converted to |
Beta Was this translation helpful? Give feedback.
-
Update: here is a repo with runnable code for quicker inspection:
https://github.com/troydraws/playground-mobx
I had been on MobX 6.0.4 before; after updating to MobX 6.1.1, In the following example, reassigning a new function to the
normalFunc
property will throw, but notactionFunc
:Previously I had been thinking of functions in observables like
normalFunc
andactionFunc
as observable references to functions. I treat them just like other keys with primitive values and can be overridden any time and trigger updates, which I had been doing extensively... Went to check the 6.1 changelog, and found out that "All annotated and non-observable props (action/flow) are non-writable. Previously writable.". I guess that's why this is now throwing?Not sure if this was an intended behaviour as a result of the change?
Beta Was this translation helpful? Give feedback.
All reactions