🚧Prevent unsubscription in OnRecieve #181
Labels
✨new-feature
New feature that does not exist
tech-debt
Code refactoring or cleanup / tech debt reduction
Milestone
Complete The Item Below
Description
Prevent an unsubscriber object from unusubscribing when its
Dispose()
method is called in anOnReceieve()
call.This can be prevented by invoking an exception. This is because if a user unsubscribes inside of an
OnReceieve()
method call, this can cause issues due to processing each subscription at a time in the reactables.To prevent this from being an issue, the for loops in the reactables all iterate the list of subscriptions from the end of the loop to the beginning so it does not try to access a subscription item that does not exist.
Why is this?
When a
SubscriptionUnsubscriber.Dispose()' method is called, it directly removes the subscription from the reactable's underlying array. The
OnReceieve()` methods are invoked in an array. This can cause a state of accessing an item that has been removed.If we throw an exception from the unsubscriber, this will prevent users from trying to call the
Dispose()
method in theOnReceieve()
call stack.How to prevent this?
Internally, have the reactable communicate a state that the reactable is in the middle of processing notifications. If this is the case, the
Dispose()
method of the unsubscriber should throw an exception.Func<bool>
and the nameisProcessing
to theSubscriptionUnsubscriber
constructor. Thebool
value will be the processing state that the reactable is currently in. A value oftrue
will mean that notifications are being processed andfalse
means it is not.Note
The
ReactableBase
class will have a private method that returns abool
value that will be passed as the new ctorparameter of the `SubscriptionUnsubsciber' class. The unsubscriber will then invoke this to check the processing
state of the reactable that the subscription belongs to.
Push
andSendError
methods of thePushReactable<TIn>
andNonDirectional.PushReactable
classes, set the state to processing before the loops start and to not processing after the loops end.PushPullReactable<TIn, TOut>.PushPull
method.Before the loop starts in the reactables, set the value of this property for each subscription
Acceptance Criteria
The items to complete in order to satisfy the Definition of Done.
ToDo Items
The items to complete in order to satisfy the Definition of Done.
Issue Dependencies
No response
Related Work
No response
Additional Information:
Change Type Labels
🐛bug
🧨breaking changes
✨new feature
♻️cicd
⚙️config
🏎️performance
🗒️documentation/code
📝documentation/product
Priority Type Labels
low priority
medium priority
high priority
Code of Conduct
The text was updated successfully, but these errors were encountered: