Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/createPersistoid.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,18 @@ export default function createPersistoid(config: PersistConfig): Persistoid {
}
})

// start the time iterator if not running (read: throttle)
if (timeIterator === null) {
timeIterator = setInterval(processNextKey, throttle)
}

lastState = state
// if no throttle, there's no point in using
// an interval, this allows background execution in RN.
if (!throttle) {
while (keysToProcess.length) {
processNextKey()
}
} else {
if (timeIterator === null) {
timeIterator = setInterval(processNextKey, throttle)
}
}
}

function processNextKey() {
Expand Down