GithubHelp home page GithubHelp logo

Comments (5)

mehulkar avatar mehulkar commented on May 22, 2024 1

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

from ember-lifeline.

mehulkar avatar mehulkar commented on May 22, 2024

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.

mehulkar avatar mehulkar commented on May 22, 2024

ping @scalvert @rwjblue

from ember-lifeline.

scalvert avatar scalvert commented on May 22, 2024

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.

scalvert avatar scalvert commented on May 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.