Git Product home page Git Product logo

Comments (7)

alexlafroscia avatar alexlafroscia commented on July 29, 2024

Yeah, you should totally be able to do that. Let me write up a test case as an example to demonstrate, and if it doesn't work I'll add that feature.

from ember-shepherd.

alexlafroscia avatar alexlafroscia commented on July 29, 2024

@davidpike7 so, you should already be able to do that with something like this:

triggerFlashMessage: on('init', function() {
  const tour = this.get('tour');
  tour.on('complete', function() {
    // Tour has been cancelled
  });
})

However, I really like the use of on to clean that up a little. I'm not sure how on works with the Evented mixin that Ember provides, which is what the tour service uses. I'll look into that, though.

from ember-shepherd.

alexlafroscia avatar alexlafroscia commented on July 29, 2024

So, I tried getting the syntax that you used working and found some confusing behavior. It seems like Ember.on works with the Ember.sendEvent method. I created an object set up like this:

  var someClass = Ember.Object.extend({
    tour: service,

    testOnInit: on('init', function() {
      var tour = this.get('tour');
      tour.on('start', function() {
        assert.ok(true, 'The `start` event was observed from the init hook');
      });
    }),

    tourDidStart: on('tour.start', function() {
      assert.ok(true, 'The `start` event was observed using the `on` helper');
    })
  }).create();

and only the hook set up in the init method was run. I'm not sure if it's possible to get it to work with the Ember.on method as well, but this Stack Overflow post seems to suggest that the events are not compatible with one another.

from ember-shepherd.

oddnavy avatar oddnavy commented on July 29, 2024

Nice work. Keep me posted with how you get on!

from ember-shepherd.

RobbieTheWagner avatar RobbieTheWagner commented on July 29, 2024

Sorry I just now saw this issue, GitHub doesn't notify me well about activity on this repo, for some reason.

from ember-shepherd.

RobbieTheWagner avatar RobbieTheWagner commented on July 29, 2024

So should we close this issue @alexlafroscia ?

from ember-shepherd.

alexlafroscia avatar alexlafroscia commented on July 29, 2024

Yeah, I'm pretty sure that it's not something that Ember supports right now, as the test I wrote in #20 shows

from ember-shepherd.

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.