Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Hacky loader that waits until initial Redux store changes settle down
const unsubscribeLoader = store.subscribe(() => {
if (selectors.loaderDelayExpired(store.getState())) {
// State settled down long enough for timer to expire - stop listening.
} else {
// Reset the timer again.
// Utility to (re)start up a timer to dismiss the loading indicator
let loaderTimer = null;
function startLoaderDelay() {
if (loaderTimer) {
loaderTimer = setTimeout(
() => store.dispatch(actions.ui.setLoaderDelayExpired(true)),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment