MessagingCenter check for instance of sender to avoid multiple calls or unsubscibe if page is remove

PatrickJelittoPatrickJelitto Member ✭✭✭

Hi Guys,

i have a view in whichs code behind serveral messages are subscribed.
I cant unsubscribe from these messages in "OnDisappearing" because i need the subscriptions to work also if the view isnt the view the user sees right now.
There can only be one instance of my view in the NavigationStack so i thought that there wont be any problems.
But it seems like removing the view from the NavigationStack wont unsucscribe its messages.
Thats why sending a message will be called as many times as many instances of this view were been created.

So maybe there is a way to subscribe a message only to an instance of this view and not for all instances of the class?

Or what would be even better is to unsubscribe to all messages once the page is removed from the NavigationStack.
I do it like so: Navigation.RemovePage(mypage);

Or maybe someone has a better idea?

Thank you very much, Gelato

Answers

Sign In or Register to comment.