Giter Club home page Giter Club logo

Comments (4)

jerel avatar jerel commented on August 30, 2024

Interesting. Does adding clock (instead of clock.time) to Ember.computed have any effect?

from ember-cli-clock.

willemdewit avatar willemdewit commented on August 30, 2024

I have the same problem, adding a binding to clock does not work. The init method on the service is not invoked, so it is not started.

from ember-cli-clock.

SirZach avatar SirZach commented on August 30, 2024

manually calling start in the init handler of my own controllers/components worked as well

from ember-cli-clock.

ryanto avatar ryanto commented on August 30, 2024

I just ran into this and learned a bit about how service injection works. Hopefully this helps anyone else running into this issue...

Services are lazily injected into Ember objects, so clock will be null until something tries to access/get it.

One way to make sure your clock service gets injected is to make your computed property accesses it.

So, instead of writing...

isAvailable: computed('availableDate', 'clock.date', function() {
  return moment(this.availableDate).isAfter(new Date());
})

you should write something the accesses the clock, forcing injection to take place. For example:

isAvailable: computed('availableDate', 'clock.date', function() {
-  return moment(this.availableDate).isAfter(new Date());
+  return moment(this.availableDate).isAfter(this.clock.date);
})

from ember-cli-clock.

Related Issues (8)

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.