For #39, I found nothing of value in my investigation. Will continue investigating and re-open if needed.
In short, one feature of the router is that it will "dispose" any route that is not rendered anymore. This means the router will tell the Relay store that any queries used by the current route is no longer active, and can be GCed if appropriate. The feature itself is especially important for larger apps where the Relay store otherwise can become quite fat and memory intensive as you browse around.
Previously, this disposing was done via a regular useEffect that would trigger when a route render function was unmounted. However, a render function unmounting doesn't necessarily mean that the route has unmounted. For example, it could be temporarily unmounted because something suspended.
This PR changes the mechanism that disposes unmounted routes from using a regular useEffect to actually pushing an event from the router when a route unmounts, and then checking by computed routeKey (which is unique per route + params) what's supposed to be disposed.
Closes https://github.com/zth/rescript-relay-router/issues/38 Closes https://github.com/zth/rescript-relay-router/issues/39
For #39, I found nothing of value in my investigation. Will continue investigating and re-open if needed.
In short, one feature of the router is that it will "dispose" any route that is not rendered anymore. This means the router will tell the Relay store that any queries used by the current route is no longer active, and can be GCed if appropriate. The feature itself is especially important for larger apps where the Relay store otherwise can become quite fat and memory intensive as you browse around.
Previously, this disposing was done via a regular
useEffect
that would trigger when a route render function was unmounted. However, a render function unmounting doesn't necessarily mean that the route has unmounted. For example, it could be temporarily unmounted because something suspended.This PR changes the mechanism that disposes unmounted routes from using a regular
useEffect
to actually pushing an event from the router when a route unmounts, and then checking by computedrouteKey
(which is unique per route + params) what's supposed to be disposed.