Global loader

This commit is contained in:
James Barnsley
2017-03-27 14:23:38 +13:00
parent b7f3eb4c14
commit 76f262fd33
11 changed files with 181 additions and 51 deletions

View File

@ -244,4 +244,21 @@ export function removeNotification( id ){
}
/**
* Loaders
**/
export function startLoading(key,source){
return {
type: 'START_LOADING',
source: source,
key: key
}
}
export function stopLoading(key){
return {
type: 'STOP_LOADING',
key: key
}
}

View File

@ -725,6 +725,24 @@ export default function reducer(ui = {}, action){
return Object.assign({}, ui, { notifications: notifications })
/**
* Loader
**/
case 'START_LOADING':
var load_queue = Object.assign({}, (ui.load_queue ? ui.load_queue : {}))
load_queue[action.key] = action.source
return Object.assign({}, ui, {load_queue: load_queue})
case 'STOP_LOADING':
var load_queue = Object.assign({}, (ui.load_queue ? ui.load_queue : {}))
if (load_queue[action.key]){
delete load_queue[action.key]
}
return Object.assign({}, ui, {load_queue: load_queue})
default:
return ui
}