Created
June 8, 2017 14:32
-
-
Save kellyrmilligan/875a41e9485b95992309c6c4560bc471 to your computer and use it in GitHub Desktop.
redux example for service worker notification
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
import { createSelector } from 'reselect' | |
// CONSTANTS | |
export const UPDATE_SERVICEWORKER = 'UPDATE_SERVICEWORKER' | |
export function updateServiceworker () { | |
return { | |
type: UPDATE_SERVICEWORKER | |
} | |
} | |
export const reducer = (state = { | |
serviceWorkerUpdated: false | |
}, action) => { | |
switch (action.type) { | |
case UPDATE_SERVICEWORKER: { | |
return { | |
...state, | |
serviceWorkerUpdated: true | |
} | |
} | |
default: | |
return state | |
} | |
} | |
const serviceWorker = (state) => state.serviceWorker | |
export const getServiceWorker = createSelector( | |
[serviceWorker], | |
(serviceWorker) => serviceWorker | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment