Files
Iris/src/js/services/ui/middleware.js

38 lines
982 B
JavaScript
Raw Normal View History

2016-11-11 16:47:32 +13:00
var actions = require('./actions.js')
var spotifyActions = require('../spotify/actions.js')
var helpers = require('../../helpers.js')
const UIMiddleware = (function(){
/**
* The actual middleware inteceptor
**/
return store => next => action => {
switch(action.type){
2016-12-13 11:08:13 +13:00
case 'CREATE_NOTIFICATION':
// start a timeout to remove this notification
var timeout = setTimeout(
function(){
store.dispatch(actions.removeNotification(action.notification.id))
},
3000
)
// we don't want to stop things happening as usual
next(action)
break
2016-11-11 16:47:32 +13:00
// This action is irrelevant to us, pass it on to the next middleware
default:
2016-12-13 11:08:13 +13:00
return next(action)
2016-11-11 16:47:32 +13:00
}
}
})();
export default UIMiddleware