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

Add support for specifying sync/async for @observes. #463

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rwjblue
Copy link
Contributor

@rwjblue rwjblue commented Sep 21, 2019

Ember 3.13 added support for specifying if an observer should be fired synchronously or asynchronously. Future versions of Ember will default to firing these observers asynchronously, but you can manually specify if you would like sync or async behaviors.

import EmberObject from '@ember/object';
import { observes } from '@ember-decorators/object';

class Foo extends EmberObject {
  @observes({
    dependentKeys: ['foo'],
    sync: false, // run asynchronously regardless of the application wide default
  })
  bar() {
    //...
  }
}

Ember 3.13 added support for specifying if an observer should be fired
synchronously or asynchronously. Future versions of Ember will default to
firing these observers asynchronously, but you can manually specify if you
would like sync or async behaviors.

```javascript
import EmberObject from '@ember/object';
import { observes } from '@ember-decorators/object';

class Foo extends EmberObject {
  @observes({
    dependentKeys: ['foo'],
    sync: false, // run asynchronously regardless of the application wide default
  })
  bar() {
    //...
  }
}
```
Copy link
Contributor

@pzuraq pzuraq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to add the sync option to @unobserves, sync and async observers get added and removed separately from each other so you need to specify the option when removing as well.

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

Successfully merging this pull request may close these issues.

None yet

3 participants