Skip to content

Conversation

danielcweber
Copy link
Collaborator

Capture the concept of a "safe observer" since it has been used and copied multiple times in the repo. ISafeObserver implements IDisposable and IObserver and can hold onto a resource. Implementors must at least dispose the resource on disposal of the SafeObserver, inheriting classes may choose to dispose the resource on other occasions as well. So far, AnonymousSafeObserver, SafeObserver and ObserverWithToken work like that are have been changed to implement ISafeObserver.

…opied multiple times in the repo. ISafeObserver implements IDisposable and IObserver and can hold onto a resource. Implementors must at least dispose the resource on disposal of the SafeObserver, inheriting classes may choose to dispose the resource on other occasions as well. So far, AnonymousSafeObserver, SafeObserver and ObserverWithToken work like that are have been changed to implement ISafeObserver.
@@ -46,7 +46,9 @@ public IDisposable SubscribeRaw(IObserver<TSource> observer, bool enableSafeguar
//
if (enableSafeguard)
{
observer = SafeObserver<TSource>.Create(observer, subscription);
var safeObserver = SafeObserver<TSource>.Create(observer);
safeObserver.SetResource(subscription);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the initialization of this subscription also be eliminated just like in the other Producer variant (in another PR of course)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it already covered in a separate PR!

@danielcweber danielcweber merged commit da20177 into dotnet:master Jun 18, 2018
@danielcweber danielcweber deleted the ISafeObserver branch June 18, 2018 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants