You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Despite what our observable is set to emit, the end result obeyed the Rx contract. That happened because `subscribe` will temrinate the subscription when the sequence terminates (or was supposed to). It doesn't mean that the problem will be taken care for us. There is also a method called `unsafeSubscribe`, which won't unsubscribe automatically.
Our subscriber's behaviour was identical to the previous example (we created an instance of `Subscriber` because `unsafeSubscribe` doesn't have overloads that take lambdas). We can see here we weren't unsubscribed and we kept receiving notifications.
335
+
336
+
`unsafeSubscribe` is unsafe in other regards as well, such as error handling. It's usefulness is limited. The documentation says that it should only be used for custom operators that use nested subscriptions. To protect such operators from receiving and illegal sequence, we can apply the `serialize` operator
We here that, despite the fact that we did not unsubscribe, the illegal notifications were filtered out.
376
+
377
+
378
+
379
+
272
380
### Extra benefits of lift
273
381
274
382
If the ability to use your custom operator in the chain like a standard operator is not convincing enough, using `lift` has one more unexpected advantage. Standard operators are also implemented using `lift`, which makes `lift` a hot method at runtime. JVM optimises for `lift` and operators that use `lift` receive a performance boost. That can include your operator, if you use `lift`.
0 commit comments