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

Modifiers are not sticky when reassigning to @observable fields #197

Closed
jeffijoe opened this issue Apr 18, 2016 · 3 comments
Closed

Modifiers are not sticky when reassigning to @observable fields #197

jeffijoe opened this issue Apr 18, 2016 · 3 comments
Labels

Comments

@jeffijoe
Copy link
Contributor

jeffijoe commented Apr 18, 2016

As discussed with @mweststrate on Discord.

When using the @observable decorator, modifiers are not sticky when reassigning.

Example:

class Stuff {
  @observable thingy = asFlat([]);

  constructor() {
    // Not sure if this is the cause..
    transaction(() => {
      this.thingy = [{more: 'stuff'}];
    });
  }
}
@mweststrate
Copy link
Member

Note that thing.replace([{more: 'stuff'}]) can currently be used to work around this.

@mweststrate
Copy link
Member

Stickyness is now solved by introducing additional decorators / modifiers. From MobX 3 onward one should use: @observable.shallow thing = [], which will be sticky

Closing this issue as [email protected] is now available, which addresses this issue. Changelog: https://github.com/mobxjs/mobx/blob/mobx3/CHANGELOG.md#300. The changes in more details: https://github.com/mobxjs/mobx/pull/725/files. Feel free to re-open if questions arise!

@jeffijoe
Copy link
Contributor Author

My man! 👍

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

No branches or pull requests

2 participants