Operator<T, U> (type)
Operators provide a way to transform events data before they are passed to the callback.
Where to use operators
type Circle = {
color: string;
radius: number;
};
// Operator that ignore all non blue circle and return the radius of all blue circles.
const blueRadius = (circle: Circle)=> circle.color !== "blue" ? null : [circle.radius];
const evtCircle = Evt.create<Circle>();
// Usage with attach, ($) because it's a fλ
evtCircle.$attach(
blueRadius,
radius => { /* ... */}
);
const radius= await evtCircle.waitFor(blueRadius);
evtCircle
.pipe(blueRadius)
.attach(radius=> { /* ... */ });Operator - Filter
Operator - Type guard
Operator - fλ
Stateless fλ
Stateful fλ
Side effect
Generic operators
Last updated
Was this helpful?
