Closed njam closed 5 years ago
Maybe I'm missing something obvious. Is there a good reason to own the "provided" on the router?
I'd like to move towards a direction where instead of just one massive state object your application can be split into multiple state objects.
I think that this makes writing tests much easier - since you don't have to deal with your entire state object when you're really just trying to test one or two aspects of state.
Given this - passing in provided state as a method wouldn't work since different route handlers will need different state.
Let me know if that makes sense or you have a different idea coming to mind!
Ok makes sense, thanks for taking the time to think about it!
Currently the
Router
keeps arbitrary application state called "provided" (with anRc
ofAny
), then passes a reference to that state to theRouteHandler
withset_provided()
, to finally pass it to the route-handler function, for example:The route-handler function is executed by the macro from
RouteHandler::view()
, which is usually called from the application.Here's the expanded macro:
Would it make sense to pass the "provided" data directly to
RouteHandler::view()
? I think this could avoid the need for putting the application state intoRc<RefCell<T>>
and usingAny
, because the application can own its state, and just pass a reference toview()
temporarily, while rendering the vdom.Basically passing the state to
view()
, which then passes it to the route-function?