as3-signals
as3-signals copied to clipboard
Adds the ReplaySignal type.
ReplaySignal is capable of replaying its dispatch history to its observers. It can also automatically replay its history to each new observer when it's added. ReplaySignal is inspired by Rx.NET's IObservable.Replay() extension method. For more info, see Lee Campbell's writeup here: http://leecampbell.blogspot.com/2010/08/rx-part-7-hot-and-cold-observables.html
Does this really need to affect the ISignal interface and the Signal class? Could this not be added extras rather than get everything at once. Therefore keeping ISignal and Signal simple and easy to use?
ReplaySignal is orthogonal to conditional listeners, but since I've advanced my branch, I support it on Replay. Conditional listeners are a nice idea. Both commits make it easier to use signals as promises (or futures).
Agreed, I just don't think everyone will use them (I would though) which is why I'm wondering if there was a way to include them and not have to put it in ISignal?
I see the potential to roll the addConditionally() functionality into the add() method (more correctly, into SignalBinding), but it feels like ambiguous API.
It most likely wouldn't break backwards compatibility. I'd bet lots of money the return type of most people's listeners is void, but there's always the edge case where a developer from JavaScript fooled himself into thinking he always needs to return TRUE but doesn't know why.
I use signals to write APIs based on promises, fluent interfaces, and a declarative asynchronous style. These pull requests are just my small contribution back to the library to help encourage developers towards this style. :)
Here's a small example of ReplaySignal in action: https://gist.github.com/1107886
nice looks good, still be good to hear what Robert thinks of the additions to ISignal and the like?
On 26 Jul 2011, at 21:19, guyinthechair wrote:
Here's a small example of ReplaySignal in action: https://gist.github.com/1107886
Reply to this email directly or view it on GitHub: https://github.com/robertpenner/as3-signals/pull/50#issuecomment-1657508