I have a web component that subscribes to a stream.
Since the web component is recreated every time it is displayed, I have to clear the subscriber and repeat it.
Now I add all the subscribers to the list and to removed() the lifecycle method that I do:
subscriptions.forEach((sub) => sub.cancel());
Now, to the problem: when the web component is not displayed, no one is listening to the stream. The problem is that the component lacks data / events when it is not displayed.
I need buffering. Events should be buffered and dispatched immediately after registering the listener. According to the documentation, buffering takes place until a listener is registered:
The controller will buffer all incoming events until the subscriber registers.
This works, but the problem is that the listener at some point is deleted and re-registered, and it seems that this does not cause buffering.
It seems that buffering occurs only initially, and not later, even if all listeners have disappeared.
So the question is: how can I buffer in this situation, when the listeners can leave and return?
dart
Kai sellgren
source share