as3-signals icon indicating copy to clipboard operation
as3-signals copied to clipboard

Adds the ReplaySignal type.

Open trxcllnt opened this issue 12 years ago • 6 comments

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

trxcllnt avatar Jul 19 '11 19:07 trxcllnt

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?

stickupkid avatar Jul 20 '11 12:07 stickupkid

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).

trxcllnt avatar Jul 20 '11 14:07 trxcllnt

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?

stickupkid avatar Jul 20 '11 14:07 stickupkid

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. :)

trxcllnt avatar Jul 20 '11 15:07 trxcllnt

Here's a small example of ReplaySignal in action: https://gist.github.com/1107886

trxcllnt avatar Jul 26 '11 20:07 trxcllnt

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

stickupkid avatar Jul 27 '11 10:07 stickupkid