I’m wondering if there is a way to re-trigger the onStartup event on a component/view.
I have a Refresh action on my onClick event and the page is definitely refreshed but it is displayed exactly as its previous state without the onStartup event being triggered. Refreshing the web browser (CTRL R or F5) gives the same result.
Is this an expected outcome?
If so, is there a way to re-trigger the onStartup event? I suppose I could have a custom script that navigates me away from the view and then back to the view but that seems hacky.
Could you move whatever logic you need to fire again into a message handler, then just dispatch a message from wherever you need to re-fire it?
That should definitely accomplish what I need for now, but eventually I would also like that logic to be triggered when the user refreshes the web browser itself.
And just so I can plan ahead I want to make sure I know what the intent of the Refresh action is.
There is a way to run a script whenever the view starts and when the page is refreshed
I’m facing this issue as well, what is the status of this? Has it been filed as a bug? You would think that issuing a refresh and redrawing the page would fire the event.
For a variety of reasons, we have to make Perspective ‘defensive’ about certain things with the move to a browser-hosted environment.
For instance - from the backend, there’s no way to distinguish between the user refreshing the tab, and the user momentarily losing connection and then getting it back (common on WiFi & cellular networks, especially for mobile devices).
So it’s somewhat of an impossible problem to solve. We could expose some event every time the ‘frontend’ of the page rebuilt - but it’s not really the same as
onStartup, because the startup event is actually triggered by the backend logic (running on the gateway) - where we have a lot more control over things and a lot more stability. If you’d find such an event useful, despite the potential drawbacks, you’re welcome to file an ideas post - but it’s not exactly a bug with the current implementation (and changing it at this point would just cause more problems).
I get it… but what is the official workaround then? This behavior causes all sorts of issues especially for business logic that depends on things happening when the page is redrawn. I don’t see why you couldn’t just issue an ajax or websocket request when the page is reload to the backend to refire those events. You are using react as your framework so communication with your backend shouldn’t be an issue.
Right - it’s not that we can’t, it’s that we didn’t when Perspective was first created, and changing it now would be a breaking change (suddenly, business logic relying on startup firing N times per session is going to start firing N*X times per session). We would have to introduce an
onRefresh or some other event type, new.
That would be very much appreciated. I already put in a feature request.
I suppose that in this case a gatewayEvent can accomplish the task, they now have only an gatewayEvent-Update.
I think hat a session-refresh can be a sort of update where a system variable, that is built at startup, change its state when the refresh of the session is done. So an update where all is the same
can be a trigger for a session refresh.
Is my hypothesis realistic?