get_rx/src/rx_workers/rx_workers library

Classes

Worker
Workers

Functions

debounce<T>(RxInterface<T> listener, WorkerCallback<T> callback, {Duration? time, Function? onError, void onDone()?, bool? cancelOnError}) Worker
debounce is similar to interval, but sends the last value. Useful for Anti DDos, every time the user stops typing for 1 second, for instance. When listener emits the last "value", when time hits, it calls callback with the last "value" emitted.
ever<T>(RxInterface<T> listener, WorkerCallback<T> callback, {dynamic condition = true, Function? onError, void onDone()?, bool? cancelOnError}) Worker
Called every time listener changes. As long as the condition returns true.
everAll(List<RxInterface> listeners, WorkerCallback callback, {dynamic condition = true, Function? onError, void onDone()?, bool? cancelOnError}) Worker
Similar to ever, but takes a list of listeners, the condition for the callback is common to all listeners, and the callback is executed to each one of them. The Worker is common to all, so worker.dispose() will cancel all streams.
interval<T>(RxInterface<T> listener, WorkerCallback<T> callback, {Duration time = const Duration(seconds: 1), dynamic condition = true, Function? onError, void onDone()?, bool? cancelOnError}) Worker
Ignore all changes in listener during time (1 sec by default) or until condition is met (can be a bool expression or a bool Function()), It brings the 1st "value" since the period of time, so if you click a counter button 3 times in 1 sec, it will show you "1" (after 1 sec of the first press) click counter 3 times in 1 sec, it will show you "4" (after 1 sec) click counter 2 times in 1 sec, it will show you "7" (after 1 sec).
once<T>(RxInterface<T> listener, WorkerCallback<T> callback, {dynamic condition = true, Function? onError, void onDone()?, bool? cancelOnError}) Worker
once() will execute only 1 time when condition is met and cancel the subscription to the listener stream right after that. condition defines when callback is called, and can be a bool or a bool Function().

Typedefs

WorkerCallback<T> = dynamic Function(T callback)