You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The web BridgeComponent connect event fires when the element appears on a page. However, if this happens on a background tab, the native BridgeComponent will ignore any messages sent because the destination is not yet active. This means the native component is not initialised.
When the user switches to the tab that has the component, the web connect event has already fired and won't happen again. There is no equivalent to viewWillLoad for the web component so I have no way of initialising the component when the user switches to the tab. You also can't use the native onViewDidLoad lifecycle event because the native component isn't initialised until it receives an event from the web so onViewDidLoad is never called.
I think I understand why we're ignoring events on an inactive destination. However maybe we could make an exception for connect events. The connect event is often used to initialise the component and set some base state ready for when the user starts interacting with it. In most cases this should be ok (preferable even?) to run on a background tab so by the time the user wants to interact with the component it has already set any state it needs.
I'd love to know if anyone else has hit this issue or if there's any recommended way of handling this situation.
If you think allowing connected events on a not-active destination is a good idea, I'm happy to draft up a PR with the change.
The text was updated successfully, but these errors were encountered:
We've been running a custom version of strada-ios in production for the last month or so with the above changes. Just adding this here in case it's helpful to someone:
The web BridgeComponent
connect
event fires when the element appears on a page. However, if this happens on a background tab, the native BridgeComponent will ignore any messages sent because the destination is not yet active. This means the native component is not initialised.When the user switches to the tab that has the component, the web
connect
event has already fired and won't happen again. There is no equivalent toviewWillLoad
for the web component so I have no way of initialising the component when the user switches to the tab. You also can't use the nativeonViewDidLoad
lifecycle event because the native component isn't initialised until it receives an event from the web soonViewDidLoad
is never called.I think I understand why we're ignoring events on an inactive destination. However maybe we could make an exception for
connect
events. Theconnect
event is often used to initialise the component and set some base state ready for when the user starts interacting with it. In most cases this should be ok (preferable even?) to run on a background tab so by the time the user wants to interact with the component it has already set any state it needs.I'd love to know if anyone else has hit this issue or if there's any recommended way of handling this situation.
If you think allowing
connected
events on a not-active destination is a good idea, I'm happy to draft up a PR with the change.The text was updated successfully, but these errors were encountered: