E
E
Evgeny Kylin2018-06-26 16:12:26
React Native
Evgeny Kylin, 2018-06-26 16:12:26

How to make work on react native setInterval in background?

The bottom line is this:
There is a certain queue Queue
and there is a setInterval

setInterval(async () => {
     if(Queue.length > 0){
            let item = Queue.shift();
      }
}, 500)

While the application is open, everything works fine, but when minimized, it stops working.
PS With ocetnik/react-native-background-timer the same story, it doesn't work in the background.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
KnightForce, 2018-10-03
@KnightForce

Regarding timeouts, if I'm not mistaken, the js stream falls asleep when I apply it in the background.
You can remember the timestamp when the timer starts, and when the application is back in the foreground, operate on the time difference.

S
Sergey Senkevich, 2014-10-13
@dmitrydeco

This query will display all items that have more than 10 floors:

SELECT i.name
FROM `items` i
    JOIN `item_attribute` ia ON ia.item_id = i.id AND ia.attribute_id = :aid
    JOIN `values` v ON v.attribute_id = ia.attribute_id
WHERE v.value > 10

:aid is the ID of the "Number of floors" attribute.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question