Global loader
This commit is contained in:
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user