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

Can't reconnect to the extension after calling disconnect #272

Open
avoskresensky opened this issue Dec 19, 2016 · 5 comments
Open

Can't reconnect to the extension after calling disconnect #272

avoskresensky opened this issue Dec 19, 2016 · 5 comments
Labels
Milestone

Comments

@avoskresensky
Copy link

It looks like the possibility to reconnect after disconnect() was broken in this commit:
f6bd08c

connect() call in function send(message) is never going to be executed again, even after an explicit disconnect() call, because the "connect" module level variable is not being reset.

@zalmoxisus
Copy link
Owner

Indeed window.__REDUX_DEVTOOLS_EXTENSION__.disconnect will not allow to connect anymore due to that commit (which was intended to disconnect all listeners when the extension is disabled), which we have to fix. However, you shouldn't need to invoke that method.

If you're using the extension API directly via window.__REDUX_DEVTOOLS_EXTENSION__.connect, you have an unsubscribe method which should do the job.

Could you please tell more about your use case?

@avoskresensky
Copy link
Author

We have an Angular2 application that's using using @ngrx/store, @ngrx/store-devtools and hot reloading.
At the "dispose" stage of the hot reload cycle we save the state of our application along with its lifted state, and restore them after the application has re-bootstrapped at the end of the hot reload.

@ngrx/store-devtools is agnostic of all of that. At the end of each hot reload cycle, @ngrx/store-devtools would make another connection to the extension, so those connections end up piling up.
There seem to be no way at the moment to make @ngrx/store-devtools reuse the connection or have it unsubscribe from it.

Our solution (which worked handsomely until that commit) was to call devToolsExtension.disconnect() during the "dispose" stage of each hot reload cycle. Since that commit it doesn't work and we're stuck with the old version of the extension.

@zalmoxisus
Copy link
Owner

zalmoxisus commented Dec 21, 2016

@ngrx/store-devtools returns an unsubscribe function, you should call for that purpose. This function will remove the listener created during the connect. However, it will not remove the instance from the monitor part, which should be fixed as well.

Disconnect is more radical, it closes all connections, not only the invoked one. In your case you don't have multiple instances, and it could be a solution.

@zalmoxisus zalmoxisus added the bug label Dec 21, 2016
zalmoxisus added a commit that referenced this issue Dec 21, 2016
Related to #272.
@zalmoxisus
Copy link
Owner

I've just published 2.11.1.1 to Chrome Store, which fixes window.__REDUX_DEVTOOLS_EXTENSION__.disconnect. We still need to remove instances for unsubscribe function, but it will be a breaking change, so we'll do it in 3.0.

@avoskresensky
Copy link
Author

Thanks for the fix.

Unfortunately @ngrx/store-devtools doesn't expose the unsubscribe function to the outside of the "extension" module. It is buried inside a chain of private calls.
I understand the "radicalness" of the disconnect approach. I might open an issue with @ngrx/store-devtools so it could be addressed properly.

@zalmoxisus zalmoxisus added this to the 3.0 milestone Jan 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants