Hi all, I have a little app which consists of a list of Todo
models. Each Todo
has a due
timestamp field.
While the app runs, I want to use a single setTimeout
and execute an action each minute. If a todo item is due, show an alert.
Something like this:
function checkModels () {
// ... do some work using models
}
function tick () {
checkModels()
setTimeout(tick, 1000 * 60)
}
tick()
That will call the tick
function every minute, and then do some work, which is what I want. What I’m not sure about is where to put that code.
Right now I have a simple route, which displays all Todos using a <TodoList />
component. Should the ticking be a service? Should it be in a controller? In a component?