-
Notifications
You must be signed in to change notification settings - Fork 56
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
Reconnecting if child reloaded #14
Comments
I'm curious to know how you think this should work from a consumer viewpoint. Should the parent somehow be notified and then forced to call While the connection is lost, Penpal should probably return a rejected promise if the parent calls any child methods. |
The problem is that patent, as far as I know, has no out of the box way to tell if child did reload apart from counting on the fact that child will ping the parent as it loads. Maybe this is the way? I mean sending a ping when child calls its own Apart from restoring the connectivity parent may also register a callback (in the future it may become an observable but since its not a standard yet let's just stick to callbacks?) which will be called each time child connection is re-established. Callback argument should probably be the same as the value Anyway: the very nature of parent side of connectin IMO implies an observable. Child side is truly a promise because if parent reloads then child is off course loaded again. |
The optimal behavior would be not to have to call |
Plus one on this feature request! If you can get it done tomorrow that'd be great 😂 Our scenario is that we have an iframe hosting another application, which transitions URLs as part of its flow. Each new URL within the iframe loses connection to the parent and we need to reestablish connection without destroying the iframe. |
👍 On my TODO list. My plan is that if the child reconnects and exposes different methods than it did on the first connection, the parent's Also, in order to allow the consumer to determine when a reconnection happens, I will allow the consumer to call Any ideas for improvement are welcome. |
Sounds good, we'll be happy to test it! |
Alright, I've published this on the Give it a shot and let me know how it works for you. |
You can read the documentation on reconnection here: https://github.com/Aaronius/penpal/tree/v3#reconnection |
Excellent! Seems to be working! Will report any bugs I come across as we continue to test. Thanks! |
I checked After the connection is established on parent side the parent sends configuration to the child. Reconnected child obviously won't get this configuration At the moment I can think of a workaround: reverse the direction of configuration flow. It's not the parent who sends configuration, it's rather the child who requests it. But it feels odd. |
In fact it's not as bad as i thought. on on For the sake of simplicity I'd say it can stay like this until more users report it would be beneficial to have it baked in. Let's just describe the technique I used |
Yeah, that works. One option would be to change |
Why not both? |
I would consider |
The awkward thing with going with |
I see it this way:
So: if the choice would be to preserve the promise and not add |
Thanks for the discussion. I'll think I'll go in that direction. |
Published in 3.0.0. |
I noticed that if I reload the page in the iframe the API is not re-established on neither side:
Penpal.connectToChild
again (even if one should call it manually)It's easy for the end user to break the experience by triggering child reload (one can always trigger it by using context menu element "Reload Frame" in Chrome for example). It's also easy to break the experience for child: if it has to reload (for either reason) the whole thing just stops working
The text was updated successfully, but these errors were encountered: