Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4870

Periodically check on some models

$
0
0

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?

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 4870

Trending Articles