(key, defaultHandler)
| 52 | } |
| 53 | |
| 54 | apply(key, defaultHandler) { |
| 55 | const hooks = this.hooks; |
| 56 | const validApplyHooks = ['onError', 'onHmr']; |
| 57 | invariant( |
| 58 | validApplyHooks.indexOf(key) > -1, |
| 59 | `plugin.apply: hook ${key} cannot be applied` |
| 60 | ); |
| 61 | const fns = hooks[key]; |
| 62 | |
| 63 | return (...args) => { |
| 64 | if (fns.length) { |
| 65 | for (const fn of fns) { |
| 66 | fn(...args); |
| 67 | } |
| 68 | } else if (defaultHandler) { |
| 69 | defaultHandler(...args); |
| 70 | } |
| 71 | }; |
| 72 | } |
| 73 | |
| 74 | get(key) { |
| 75 | const hooks = this.hooks; |
no outgoing calls
no test coverage detected