Last active
March 24, 2018 14:53
-
-
Save hedgerh/64a98583bd3a3edde8853c45ee9f1e5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* countdown() { | |
yield call(delay, toMilliseconds(480)); | |
yield put(showLogoutWarning()); | |
yield call(delay, toMilliseconds(120)); | |
yield put(logout()); | |
} | |
function* watchForActivity() { | |
while (true) { | |
yield takeLatest(action => action.type !== ' SHOW_LOGOUT_WARNING', countdown); | |
} | |
} | |
function* watchNavigation() { | |
while(true) { | |
let task; | |
const action = yield take(['NAVIGATE', 'LOGOUT']); | |
if (task) { | |
yield cancel(task); | |
} | |
if (action.type === 'NAVIGATE' && isSensitiveRoute(action.url)) { | |
task = yield fork(watchForActivity); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment