UNPKG

483 BJavaScriptView Raw
1
2export default function (option, method, event) {
3 const type = event.type;
4
5 let before;
6 let after;
7
8 if (type in option.listener) {
9 before = typeof option.listener[type].before === 'function' ? option.listener[type].before.bind(null, event) : null;
10 after = typeof option.listener[type].after === 'function' ? option.listener[type].after.bind(null, event) : null;
11 }
12
13 Promise.resolve().then(before).then(method.bind(null, event)).then(after);
14}