buffer events to avoid lifecycle issues
This commit is contained in:
@@ -58,10 +58,25 @@ class EngineBoundIntentStream extends _$EngineBoundIntentStream {
|
|||||||
final sharingItentStream = ref.watch(sharingIntentStreamProvider);
|
final sharingItentStream = ref.watch(sharingIntentStreamProvider);
|
||||||
final appWidgetLaunchStream = ref.watch(appWidgetLaunchStreamProvider);
|
final appWidgetLaunchStream = ref.watch(appWidgetLaunchStreamProvider);
|
||||||
|
|
||||||
return MergeStream([
|
// Create a broadcast stream controller to buffer events
|
||||||
sharingItentStream.transform(_contentParserTransformer),
|
final controller = StreamController<SharedContent>.broadcast();
|
||||||
appWidgetLaunchStream.transform(_contentParserTransformer),
|
|
||||||
]);
|
final subscription =
|
||||||
|
MergeStream([
|
||||||
|
sharingItentStream.transform(_contentParserTransformer),
|
||||||
|
appWidgetLaunchStream.transform(_contentParserTransformer),
|
||||||
|
]).listen(
|
||||||
|
controller.add,
|
||||||
|
onError: controller.addError,
|
||||||
|
onDone: controller.close,
|
||||||
|
);
|
||||||
|
|
||||||
|
ref.onDispose(() async {
|
||||||
|
await subscription.cancel();
|
||||||
|
await controller.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
return controller.stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
Reference in New Issue
Block a user