Comments (5)
Something explicit in the readme would be ok too. I think using registerDisposable is a fine way to convert usage.
from ember-lifeline.
Or add a function like this:
/**
* Ember Lifeline provides some primitives to dispose off event handlers bound to Ember.Evented
* objects. This helper puts them together allowing the user to cleanly add and remove
* listeners in the lifecycle of the listener.
*
* @function addEventedEventListener A helper to use ember-lifeline with Ember.Evented
* @param {Object} listener The `this` context from where this is called
* @param {Object} target The target that triggers the event name, that we want to listen to
* @param {String} eventName The name of the event to bind the event handler to
* @param {Function} handler A reference to the event handler
*/
export function addEventedEventListener(listener, target, eventName, handler) {
const boundMethod = bind(listener, handler);
target.on(eventName, boundMethod);
registerDisposable(listener, () => target.off(eventName, boundMethod));
}
usage:
addEventedEventListener(this, this.get('myService'), 'someEventName', this.handler)
from ember-lifeline.
from ember-lifeline.
Hey @mehulkar, thanks for opening this discussion. Sorry for the delay in getting back to you; I was delayed in responding while processing what this means/would look like.
I'm open to having some API that we interact with that allows us to track usages of Ember.Evented
's APIs, but am not entirely sure what that should look like. I'm not convinced that we should overload the addEventListener
implementation to work for both DOM and Evented events. This feels a bit odd to me, and I can't quite put my finger on why yet.
I'll start exploring what this could look like. Meanwhile, I'm curious what @rwjblue thinks.
from ember-lifeline.
Just doing a bit of cleanup on issues in this repo. If this issue is closed in error please reopen!
from ember-lifeline.
Related Issues (20)
- For Ember 4 compatibility, add "for" and "since" attributes to options in all calls to deprecate() HOT 1
- test-support types not found after upgrade to 7.0.0
- Type imports only available in dist/ and src/
- Type miss-match between `runTask` and `cancelTask` HOT 1
- cancelId in cancelTask should be optional
- IE11 support
- [IE11] support for `{ once: true }` HOT 1
- Issue with @types/ember after upgrade HOT 1
- Loosen type from EmberObject to interface HOT 4
- assert.expect has unexpected behavior HOT 5
- Typescript errors when running in host app HOT 5
- After Ember 3.2 upgrade, didRender() hook in a component with poll is not fired appropriately in qunit tests HOT 8
- PollTask doesn't check if the task is cancelled or not HOT 2
- Assertion in `addEventListener` does not line up with what is advertised in the docs HOT 1
- Watch / polyfill / update ongoing "destructors" RFC HOT 2
- pollTask should have pollTaskEnd and/or pollTaskUntil(n) helpers
- Parameter type error HOT 1
- Framework objects look to be included in undestroyed objects when using setupLifelineValidation HOT 10
- Run dependabot less frequently HOT 2
- Documentation and code do not agree on runDisposables HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-lifeline.