Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Start immediately after Destroy does not work as expected. #42

Closed
Heedster opened this issue Sep 16, 2015 · 3 comments
Closed

Start immediately after Destroy does not work as expected. #42

Heedster opened this issue Sep 16, 2015 · 3 comments

Comments

@Heedster
Copy link

On user activity, I used to do this.

if(this.poller){
this.poller.stop()
} 
this.poller.start()

so that poller would restart. I have a 30 sec delay in poller which will delay the next calls.

Recently I changed it to..

if(this.poller){
this.poller.destroy()
}
this.poller.start()

Now I observed that, The network call does not happen immediately, it will just happen after 30 sec and every 30 sec there after. Somehow destroy() is not stopping the poller when start is called immediately after that. Is it some race condition triggering this behaviour.?

For now I have changed it back to stop() and that fixes the issue.

@uzikilon
Copy link
Owner

I will look into why this is happening - but that is interesting.

However, calling poller.destroy() basically means you are cleaning up all references internally and never intend to use the poller again.
If you have intentions to restart the poller later, stop is the right method.

@Heedster
Copy link
Author

Did you find out why this is happening?

@uzikilon
Copy link
Owner

uzikilon commented Oct 1, 2015

When destroying the poller all event listeners are being destroyed, so trying to re-use a destroyed poller can do weird things.
Basically if you are re-using a destroyed poller you shouldn't destroy it, but stop it,

Only destroy the poller if you do not intend to use it anymore and want to do some garbage collection

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants