Hi all! I tried searching for something along these lines, so sorry if I missed something. I am wanting to reuse defrouter with some custom rendering of a transition from one route to the other. It seems like this isn’t currently possible because we don’t have access to the route that is being routed away from or it’s factory and props. Does anyone have any insight as to some of the different considerations and possibilities for how we could not have to recreate the whole wheel of dynamic routers but enhance them with this information?
So, it isn’t designed for that particular use-case, but here’s what I’d do: You can easily look at the current query of the router to figure out which thing is the current route. There is also a function the get the current “path”. I’d make a mutation that obtains this information first, stores it somewhere, and then invokes the routing. Then you can turn on always render, and use that info combined with the new route to do your transition.
(remember that the component is on the metadata of the query)
you could also use the state in the db to figure this before/after picture out. The routers are normalized, and have a current route. Each frame of your render is (from Fulcro’s perspective) a pure function of that data. So a picture of that data before/after would give you all you need.
Here’s a scheme: Your “route” mutation could save the entire app state of “before” somewhere (global atom, whatever). Now you can use ui->props and comp/factory and other utility functions against that db to obtain what your need. It’s all normalized.
(dynamic queries of the routers are also visible as a pure function of state, so (get-query SomeRouter old-state-map) would give you the old query, which in turn as the component in metadata on the query
I am also interested in building transitions between routes on my native app.
We ended up doing our own higher level component that works for now, but we may need to revisit this from a routing perspective again. This is all very helpful. Thanks again @tony.kay for your helpfulness and sharing so much.