MCPcopy Create free account
hub / github.com/jamiebuilds/create-react-context / createEventEmitter

Function createEventEmitter

src/implementation.js:43–63  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

41};
42
43function createEventEmitter(value) {
44 let handlers = [];
45 return {
46 on(handler) {
47 handlers.push(handler);
48 },
49
50 off(handler) {
51 handlers = handlers.filter(h => h !== handler);
52 },
53
54 get() {
55 return value;
56 },
57
58 set(newValue, changedBits) {
59 value = newValue;
60 handlers.forEach(handler => handler(value, changedBits));
61 }
62 };
63}
64
65function onlyChild(children): any {
66 return Array.isArray(children) ? children[0] : children;

Callers 1

ProviderClass · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…