I have been playing round with Volt for few days and love the simple bindings it allows. I was trying to show a 'live clock' on the page by using Time.now. I have tried binding Time.now to the various collections from within the controller but it didn't quite work (I had to refresh the page for the new time to show up, beating the purpose). Is there any way to achieve this without the use of Javascript?
Asked
Active
Viewed 97 times
1 Answers
2
Right now we don't have bindings on Time done yet. Its on the todo list, but at the moment you'll have to manually update it. You could do something like this in a lib file, then require it in a controller with `require '{component_name}/lib/{file}'
class Time
def live
dep = Volt::Dependency.new
dep.depend
Volt::Timers.client_set_timeout(1000) do
dep.changed!
end
self
end
end
Then in the controller, you can call .live on a Time instance to get back an instance of the Time class that will reactively update.
Let me know if that works. :-)

Ryan
- 956
- 7
- 8
The time now is {{ page._time }}
` Is something missing or wrong ? – Abdul Jaleel Jun 11 '15 at 17:47