Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AllGistsEqual/6373510c3d8091ac87a960d28aa2b0fe to your computer and use it in GitHub Desktop.
Save AllGistsEqual/6373510c3d8091ac87a960d28aa2b0fe to your computer and use it in GitHub Desktop.
import {
INIT_APPLICATION,
} from '../../actions/application.actions'
import manifest from '../../../../app.json'
const { expo: { name, version: manifestVersion } } = manifest
const applicationMiddleware = ({ getState }) => (next) => (action) => {
switch (action.type) {
case INIT_APPLICATION: {
const { application: { version: oldVersion } } = getState()
console.log(`oldVersion: (${oldVersion}) // manifestVersion: (${manifestVersion})`)
if (oldVersion === -1 || oldVersion === manifestVersion) {
// enrich payload of current action and pass it on with next()
next({
...action,
payload: {
...action.payload,
name,
version: manifestVersion,
},
})
break
}
// here be code for version updates
break
}
default: {
next(action)
}
}
}
export default applicationMiddleware
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment