run static method
StreamSubscription<LiveActivityData>
run({
- required String id,
- required Stream<
LiveActivityData> stream, - bool autoEnd = true,
- void onError(
- Object error
Implementation
static StreamSubscription<LiveActivityData> run({
required String id,
required Stream<LiveActivityData> stream,
bool autoEnd = true,
void Function(Object error)? onError,
}) {
bool started = false;
final sub = stream.listen((data) async {
if (!started) { await start(id: id, data: data); started = true; }
else { await update(id: id, data: data); }
}, onError: onError, onDone: () async {
if (autoEnd && started) await end(id);
}, cancelOnError: false);
return sub;
}