Same than .evtDiff but post only when .evtChang post.
.pipe(...)
Same as evt.pipe(...) but return a StatefulEvt. Be aware that the current state of the StatefulEvt must be matched by the operator ( if any ) when invoking .pipe(), elst an exception will be thrown.
Converting an Evt into a StatefulEvt
Use the method method .toStateful(initialState) of Evt. Example:
You do not need to pass an initialization value to .toStateful(), if you don't the state will be initialized with undefined and the returned StatefulEvt will be of type<T | undefined>. This is usefull when using .toStateful after Evt.merge(). See next example.
import { StatefulEvt, StatefulReadonlyEvt } from "evt";
//Return an event that post every second.
function generateEvtTick(delay: number): StatefulReadonlyEvt<number> {
const evtTick= new StatefulEvt(0);
setInterval(()=> evtTick.state++, delay);
retrun evtTick;
}
const evtTick= generateTick(1000);
evtTick.state++; // TS ERROR
evtTick.post(2); // TS ERROR
/**
* Post and enforce that .evtChange and .evtChangeDiff
* be posted even if the state has not changed.
*
* If no argument is passed the post is performed with the current state.
*
* Returns post count
**/
postForceChange(wData?: readonly [T]): number;
import { Evt } from "evt";
const evtText= Evt.create("foo");
//x is Evt<string>
const x= evtText.toStateless();