question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to convert Ember.Evented usage

See original GitHub issue

Ability 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:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mehulkarcommented, Oct 17, 2018

Something explicit in the readme would be ok too. I think using registerDisposable is a fine way to convert usage.

0reactions
scalvertcommented, Jan 31, 2022

Just doing a bit of cleanup on issues in this repo. If this issue is closed in error please reopen!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found