()
| 9 | export function Lifecycle(Base) { |
| 10 | return class Lifecycle extends Base { |
| 11 | initLifecycle() { |
| 12 | const hooks = [ |
| 13 | 'init', |
| 14 | 'mounted', |
| 15 | 'beforeEach', |
| 16 | 'afterEach', |
| 17 | 'doneEach', |
| 18 | 'ready', |
| 19 | ]; |
| 20 | |
| 21 | this._hooks = {}; |
| 22 | this._lifecycle = {}; |
| 23 | |
| 24 | hooks.forEach(hook => { |
| 25 | const arr = (this._hooks[hook] = []); |
| 26 | this._lifecycle[hook] = fn => arr.push(fn); |
| 27 | }); |
| 28 | } |
| 29 | |
| 30 | callHook(hookName, data, next = noop) { |
| 31 | const queue = this._hooks[hookName]; |