Browse Source

Add after callback to storage

pull/3411/head
Artur Arseniev 5 years ago
parent
commit
7f02f4711a
  1. 14
      src/storage_manager/index.js

14
src/storage_manager/index.js

@ -37,6 +37,7 @@ import LocalStorage from './model/LocalStorage';
import RemoteStorage from './model/RemoteStorage';
const eventStart = 'storage:start';
const eventAfter = 'storage:after';
const eventEnd = 'storage:end';
const eventError = 'storage:error';
@ -214,6 +215,7 @@ export default () => {
? st.store(
toStore,
res => {
this.onAfter('store', res);
clb && clb(res);
this.onEnd('store', res);
},
@ -259,6 +261,7 @@ export default () => {
result[itemKeyR] = res[itemKey];
}
this.onAfter('load', result);
clb && clb(result);
this.onEnd('load', result);
},
@ -301,6 +304,17 @@ export default () => {
}
},
/**
* On after callback (before passing data to the callback)
* @private
*/
onAfter(ctx, data) {
if (em) {
em.trigger(eventAfter);
ctx && em.trigger(`${eventAfter}:${ctx}`, data);
}
},
/**
* On end callback
* @private

Loading…
Cancel
Save