Last active
March 1, 2019 17:27
-
-
Save doasync/a4d2e49e27d9e2ad7b9017caa9463d39 to your computer and use it in GitHub Desktop.
Effector: group events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const groupEvents = events => { | |
for (const fromEvent of events) { | |
const eventCreate = fromEvent.create; | |
fromEvent.create = (data, fullName, args) => { | |
const [meta = {}] = args; | |
if (meta !== null && !meta.single) { | |
for (const toEvent of events) { | |
if (toEvent !== fromEvent) { | |
toEvent(data, { single: true }); | |
} | |
} | |
} | |
eventCreate(data, fullName, args); | |
}; | |
} | |
}; | |
// groupEvents([onInput, onChange]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment