Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onMainThread triggering multiple times #28

Open
askaralic opened this issue Feb 27, 2017 · 12 comments
Open

onMainThread triggering multiple times #28

askaralic opened this issue Feb 27, 2017 · 12 comments

Comments

@askaralic
Copy link

When i call postToMainThread or simple post onMainThread is calling many times . triggering count is not predictable .

@nunogoncalves
Copy link
Collaborator

nunogoncalves commented Feb 27, 2017

Hi @AskarAli.
As you probably know, we developers are just that, developers. Not witches, nor magicians, even if sometimes people believe so.
That being said, we can't just guess the problem without more information. Can you provide more insight, your use case in particular? How are you using SwiftEventBus? Are you sure you're not posting multiple times? Just throw us a bone here please. :)

Thanks for using SwiftEventBus by the way.

@askaralic
Copy link
Author

I have used this for a test purpose while tapping a button i have sent the post code as you mentioned in usage and printed the value thats it

@nunogoncalves
Copy link
Collaborator

Can you share the code? Or the project?

@jscarney
Copy link

jscarney commented Apr 25, 2017

I have the same issue. I have used the event bus in a couple projects but the number of times a message is received is unpredictable. I put in traps to print to debug console when the POST is done and then inside the listener I print when the message is received. I even try unregistering the event inside the onMainThread routine, but even with that I sometimes get an extra call as if the message was posted again (but it was not). I don't have an isolated project at the moment to send. The event bus is in several places in my projects, but the duplicate calls of the listener are problematic. I did not notice for some time as mostly I was just using it to know when to reload a table. A second or third call to reload the table was not a problem - not noticeable. But later I used the events to control more complex sequential logic (e.g. doing multiple reads from firebase).

@mikeuv
Copy link

mikeuv commented May 18, 2017

I have exactly the same problem right know. Let me know if you need code in order to understand my problem.

@wokenshin
Copy link

If more than one OC project is better

@talk2cerlin
Copy link

Make sure you are unregistering properly or else everytime you register, it adds a new handler.

@satishVekariya
Copy link
Contributor

@AskarAli Print instance in onMainThread if all address are different then may be problem in your code!!

@hoang-bondle
Copy link

@AskarAli please make sure that you are subscribing to event in viewWillAppear and unregister in view viewWillDisappear

@sobakasu
Copy link

sobakasu commented Oct 8, 2019

511xXaL5IAL SX258_BO1,204,203,200

@rbugaian
Copy link

@AskarAli @jscarney @mikeuv Just make sure to call SwiftEventBus.unregister(YOUR_TARGET_OBJECT) before subscribing/registering. Had the same problem.
SwiftEventBus does not filter out multiple subscriptions of a target.

@daerimin
Copy link

daerimin commented Jul 7, 2022

Make sure you are unregistering properly or else everytime you register, it adds a new handler.

THIS was killing me and I guess I didn't read the docs... thank you for pointing this out!!!

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

No branches or pull requests