Ability to convert Ember.Evented usage
See original GitHub issueAbility to replace Ember.Evented
with an comparable API would be great. Example:
Current
// app/services/foo.js
import Evented from '@ember/object/evented';
export default Service.extend(Evented, {
triggerEvent() {
this.trigger('someEvent');
}
});
// app/components/foo-bar.js
export default Component.extend({
foo: service(),
init() {
this._super(...arguments);
this.get('foo').on('someEvent', () => alert('called'))
}
})
Desired
I think a good way to do this would be to add trigger
to the ContextBoundEventListenersMixin
, so that it can be mixed into any object and can trigger events and register listeners.
// app/services/foo.js
import { ContextBoundEventListenersMixin } from 'ember-lifeline';
export default Service.extend(ContextBoundEventListenersMixin, {
triggerEvent() {
this.trigger('someEvent');
}
});
// app/components/foo-bar.js
import { addEventListener, runDisposables } from 'ember-lifeline';
export default EmberObject.extend({
foo: service(),
init() {
this._super(...arguments);
addEventListener(this, this.get('foo'), 'someEvent', () => alert('called'));
}
willDestroy() {
runDisposables(this);
}
})
Thoughts?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Deprecate Usage of Ember Evented in Ember Data - GitHub
Today there are better ways to do everything that once needed events. Removing the usage of the Ember.Evented mixin will make it easier...
Read more >Ember.Evented - 2.13 - Ember API Documentation
This mixin allows for Ember objects to subscribe to and emit events. ... It is good to use one when you only care...
Read more >Ember interactivity: Events, classes and state - MDN Web Docs
At this point we'll start adding some interactivity to our app, providing the ability to add and display new todo items.
Read more >Ember Octane vs old Ember the ability of using `reopen ...
So I working on converting a them main ...
Read more >Data Down Action... Down in Emberjs - Using Ember.Evented
What is Ember.Evented? Have you ever heard of it? It's a mixin that can be used in any Ember Object you want. It...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Something explicit in the readme would be ok too. I think using registerDisposable is a fine way to convert usage.
Just doing a bit of cleanup on issues in this repo. If this issue is closed in error please reopen!