-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sandbox.collect() #322
Comments
👍 |
I'm really glad to see that you considered upstreaming this behaviour to EE2 as its useful in the general event space. For Aura, would you be interested in putting together a PR that brought this behavior to the project? We could of course punt on this if it does end up being a part of eventemitter2. My only reservations are probably the benchmarks mentioned in the other thread, which would be great to further optimize on. |
Will give it a shot (doing it within Aura) soon! |
I tried adding a I think it would have been nicer if Aura would approach the underlying emitter implementation as a black box. I simply got stuck on getting any unit tests running. We could take this as a future improvement (#323) if you all agree. I'm therefore considering again (EventEmitter2/EventEmitter2#102) landing a |
The description for hij1nx/EventEmitter2 has received a "[Not actively developed]" designation. I could potentially take the route of adding |
Hi guys, I'm a huge fan of scalable javascript architecture and here are my 2 cents - stand alone sandbox module with lots of cool features, would you mind to give me some feed back about it, if you have time? Thank you. |
sandbox.emit()
is good when you can "fire and forget" an event. But there are times when a component needs to collect results from other components (for when a Service Locator implementation is needed). This can still be achieved withsandbox.emit()
through some hacky ways like:However, this only works when all listeners can return results synchronously. If results are resolved asynchronously, there is still another hack that can be applied: Let listeners return a Promise right away, and then resolve the underlying Deferred asynchronously. But this solution would involve some ugly boilerplate code on the application side every time such asynchronous query needs to be executed. Guessing something like:
Of course, an application can write a utility to hide this ugliness, but I was thinking that this sort of asynch collection facility could be built into Aura. Maybe something like:
I've already proactively issued a pull request for EventEmitter2 to also have a
.collect()
method there -- have no idea if it will fly: EventEmitter2/EventEmitter2#102At the worst case, this can be achieved entirely within Aura by a hack (or shall we say, cleverness) as the above.
The text was updated successfully, but these errors were encountered: