upta / pubsub

An extremely light-weight, easy to use PCL pub/sub library
Apache License 2.0
219 stars 53 forks source link

Subscribing multiple times causes the action to be triggered more than once. #14

Closed sbolum closed 6 years ago

sbolum commented 6 years ago

When we add subscribe code to somewhere like activity onCreate, page load etc, it's possible for this code to be called multiple times. Than, this causes the message action being called multiple times.

I think there should be a precaution or at least an option to prevent this situation.

upta commented 6 years ago

There are definitely valid scenarios in which you'd want to subscribe multiple times to the same kind of event.

In those kinds of "OnCreate" scenarios it's generally a good practice to unsubscribe inside your "OnDestroy"

On Nov 27, 2017 11:06 PM, Serdar notifications@github.com wrote:

When we add subscribe code to somewhere like activity onCreate, page load etc, it's possible for this code to be called multiple times. Than, this causes the message action being called multiple times.

I think there should be a precaution or at least an option to prevent this situation.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fupta%2Fpubsub%2Fissues%2F14&data=02%7C01%7Cupta%40outlook.com%7C475a5cb4aef04c3bb04308d5362e92fe%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636474496011253127&sdata=b4ewzZ9haDr9UicavlZixbjGGJ0bewg2G04ASTgOHMA%3D&reserved=0, or mute the threadhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FADKEjP7T-3Uj9eMtMdWl_pMjcJ9S83pWks5s67D_gaJpZM4Qsx-8&data=02%7C01%7Cupta%40outlook.com%7C475a5cb4aef04c3bb04308d5362e92fe%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636474496011253127&sdata=33SG4WTGqiFDBfwsAmRXforjoD1HOOk7IUulf%2FTVhYM%3D&reserved=0.

sbolum commented 6 years ago

Ok then, I'll reevaluate my case and find a solution. Thanks