ember icon indicating copy to clipboard operation
ember copied to clipboard

Give developers better feedback when they try to mutate `state` property

Open taras opened this issue 5 years ago • 0 comments

Microstates are immutable, as such changing value on state property doesn't make sense. Unfortunately, some components do this without the developer realizing it.

Currently, if Ember tries to set state property, the developer will get an error like this: Uncaught TypeError: Cannot set property state of #<Primitive> which has only a getter.

This is not very descriptive. Instead, we should give them an error that tells them why this might be happening. Something like this: Ember tried to mutate the state property of a microstate locatet at [path]. You might have the state property two way bound to a property of a component. [link to readme with more information].

To make this change, we could add a setter for the state property to each primitive type. There might be a better way to do it, but it'd require changes to Microstates.js library.

taras avatar Nov 29 '18 23:11 taras