everAll function
Worker
everAll(
- List<
RxInterface> listeners, - WorkerCallback callback, {
- dynamic condition = true,
- Function? onError,
- void onDone()?,
- bool? cancelOnError,
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.
Implementation
Worker everAll(
List<RxInterface> listeners,
WorkerCallback callback, {
dynamic condition = true,
Function? onError,
void Function()? onDone,
bool? cancelOnError,
}) {
final evers = <StreamSubscription>[];
for (var i in listeners) {
final sub = i.listen(
(event) {
if (_conditional(condition)) callback(event);
},
onError: onError,
onDone: onDone,
cancelOnError: cancelOnError,
);
evers.add(sub);
}
Future<void> cancel() async {
for (var i in evers) {
i.cancel();
}
}
return Worker(cancel, '[everAll]');
}