UNPKG
mirrorv
Version:
latest (0.0.5)
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1
A fork of https://github.com/mirrorjs/mirror
github.com/biuuu/mirror
biuuu/mirror
mirrorv
/
src
/
hook.js
15 lines
(10 loc)
•
269 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export
const
hooks = []
export
default
function
hook
(
subscriber
) {
if
(
typeof
subscriber !==
'function'
) {
throw
new
Error
(
'Invalid hook, must be a function!'
) } hooks.
push
(subscriber)
return
() =>
{ hooks.
splice
(hooks.
indexOf
(subscriber),
1
) } }