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
So recently I have been attempting to find a simple pattern for unsubscribing. I really am enjoying SubSink however I still need to do a whole ngOnDestory() when using it.
I have looked into a few other libraries and the one I have come across that I have found with the best patterns for removing ngOnDestory() has been the @ngneat/until-destroy library. However it's patterns for tracking observables is a bit cumbersome.
So I had the idea of using subsink with @ngneat/until-destroy. @ngneat/until-destroy offers the option to provide the name of a Subscription array member and it will unsubscribe when the component is destroyed. However SubSink stores it's array internally so I thought instead we could do something like this -
classSubSinkextendsArray<SubscriptionLike>
Given that SubSink has no methods that overlap with an Array this change can be non breaking and allow for this pattern.
As it stands right now if I wanted to use this pattern with SubSink I would need to provide UntilDestory with the private reference to subs._subs which I feel is somewhat of an Anti-pattern.
So recently I have been attempting to find a simple pattern for unsubscribing. I really am enjoying SubSink however I still need to do a whole
ngOnDestory()
when using it.I have looked into a few other libraries and the one I have come across that I have found with the best patterns for removing
ngOnDestory()
has been the@ngneat/until-destroy
library. However it's patterns for tracking observables is a bit cumbersome.So I had the idea of using
subsink
with@ngneat/until-destroy
.@ngneat/until-destroy
offers the option to provide the name of a Subscription array member and it will unsubscribe when the component is destroyed. However SubSink stores it's array internally so I thought instead we could do something like this -Given that SubSink has no methods that overlap with an Array this change can be non breaking and allow for this pattern.
As it stands right now if I wanted to use this pattern with SubSink I would need to provide
UntilDestory
with the private reference tosubs._subs
which I feel is somewhat of an Anti-pattern.What are your thoughts @wardbell?
The text was updated successfully, but these errors were encountered: