Inside my handlebars template:
Today's date: {{currentDate}} Current Time: {{currentTime}}
Inside my helpers:
Ember.Handlebars.registerBoundHelper 'currentDate', (option) -> moment().format('LL'); Ember.Handlebars.registerBoundHelper 'currentTime', (option) -> moment().format('h:mm:ss a');
How would I go about updating the currentTime to the view every 1 second?
I have read the Ember recommends Ember.run.later
but I can't quite figure out where to put it and how to call it using this helper.
Module: ember-metal. Runs the passed target and method inside of a RunLoop, ensuring any deferred actions including bindings and views updates are flushed at the end. Normally you should not need to invoke this method yourself.
Ember. js is an open source, free JavaScript client-side framework used for developing web applications. It allows building client side JavaScript applications by providing a complete solution which contains data management and an application flow. The original name of Ember.
It should also be mentioned that Ember is purely a frontend framework. It has a number of ways of interacting with the backend of your choice, but this backend is not in any way handled by Ember itself.
Ember. js is one component of a complete front end stack built and supported by the Ember core team.
You can use Ember.run.later like you would normally use setTimeout
Ember.run.later((function() { //do something in here that will run in 2 seconds }), 2000);
I'm not sure of the internals, but I know that integration testing Ember requires that you use run.later (if you don't the test code won't wait for the timeout to finish).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With