1 | export default function emitter(obs) {
|
2 | function value(x) {
|
3 | obs._emitValue(x)
|
4 | return obs._active
|
5 | }
|
6 |
|
7 | function error(x) {
|
8 | obs._emitError(x)
|
9 | return obs._active
|
10 | }
|
11 |
|
12 | function end() {
|
13 | obs._emitEnd()
|
14 | return obs._active
|
15 | }
|
16 |
|
17 | function event(e) {
|
18 | obs._emit(e.type, e.value)
|
19 | return obs._active
|
20 | }
|
21 |
|
22 | return {
|
23 | value,
|
24 | error,
|
25 | end,
|
26 | event,
|
27 |
|
28 | // legacy
|
29 | emit: value,
|
30 | emitEvent: event,
|
31 | }
|
32 | }
|