Skip to content

Understanding Signals vs Events

Churchill Lee edited this page Jun 7, 2016 · 2 revisions

What's Signals and Events you ask?

The most common analogy is comparing age (signal) to birthday (event)

As we know, in CycleJS Stream library like xstream / RxJS (depending on which release) is a peer dependency.

The confusing part is that streams can model both Signals and Events.. so the developer needs to know and make decision to convert the stream to either a Signal or an Event stream.

In Rx/xstream signal streams are represented as observables with replay/memory.

Event streams are represented as observables without memory.

Rule of thumb.

If you have a stream that holds value over time ( state$? ), then most probably it's a Signal.. and it needs to be replay-ed in Rx or remember-ed in xstream to convert it to a memory stream.

Caveats

From xstream 4.0.0 onwards, certain things like startWith will turn a stream into a memory stream.