Member-only story
RxJS: Understanding Lettable Operators
An update: lettable operators are now officially pipeable operators.
The version 5.5.0 beta of RxJS introduces lettable operators.
Lettable operators offer a new way of composing observable chains and they have advantages for both application developers and library authors. Let’s look briefly at the existing composition mechanisms in RxJS and then look at lettable operators in more detail.
Using the bundle
When the entire — and rather large — RxJS bundle is imported, all operators will have been added to Observable.prototype
. So observables can be composed by chaining the operator methods, like this:
The obvious disadvantage with this approach is that the applications will contain everything that’s in RxJS, even if it’s not required.
Using prototype patching
RxJS includes — under its add
directory — modules that patch Observable
and Observable.prototype
. These can be imported on a per-operator basis, allowing developers to import only…