Skip to content

Instantly share code, notes, and snippets.

@rt2zz
Created November 22, 2016 01:58
Show Gist options
  • Save rt2zz/950c4323a1e8b8eb9368aae973a325fa to your computer and use it in GitHub Desktop.
Save rt2zz/950c4323a1e8b8eb9368aae973a325fa to your computer and use it in GitHub Desktop.
// time iterator (read: debounce)
if (timeIterator === null) {
timeIterator = setInterval(processNextReducer, debounce)
}
function flush () {
storesToProcess.forEeach(processNextReducer)
}
function processNextReducer () {
if (storesToProcess.length === 0) {
clearInterval(timeIterator)
timeIterator = null
return
}
let key = storesToProcess[0]
let storageKey = createStorageKey(key)
let endState = transforms.reduce((subState, transformer) => transformer.in(subState, key), stateGetter(store.getState(), key))
if (typeof endState !== 'undefined') storage.setItem(storageKey, serializer(endState), warnIfSetError(key))
storesToProcess.shift()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment