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
Currently, the router is designed in a similar fashion as in most dynamically-typed languages and therefore makes some compromises. We could better leverage Scala's type system for a more sophisticated design. The exact details still have to be worked out, but here's a sketch of what I think we should be heading to:
For performance reasons, a page should only be constructed once it is loaded and destroyed when the page changes.
Right now, pages are instantiated lazily, but never destroyed.
There should be type-safe matchers such as StrArg, IntArg and the like. The user may want to define own matchers as well.
Right now, every argument is a string and needs to be converted manually.
Channel-awareness: The idea is to be consistent with the rest of the Widok ecosystem.
The current route should be stored in a channel.
This allows for better composability; as of now, a route change re-renders the whole page. This is not always desired. Sometimes only a certain part of the page should be replaced. An example are Bootstrap pages which are usually composed of a header, body and a footer. There it makes sense to update only the body upon page change. Thanks to channels, the header does not even have to be static. It could reside in an object providing channels which pages could send data to.
Arguments should be stored in a channel.
Instead of reloading the whole page, the page is constantly getting notified about changing argument(s). As channels already provide unique, this should be easy to implement. Then, it only re-renders those parts which are actually related to the changed argument.
Currently, the router is designed in a similar fashion as in most dynamically-typed languages and therefore makes some compromises. We could better leverage Scala's type system for a more sophisticated design. The exact details still have to be worked out, but here's a sketch of what I think we should be heading to:
Right now, pages are instantiated lazily, but never destroyed.
StrArg
,IntArg
and the like. The user may want to define own matchers as well.Right now, every argument is a string and needs to be converted manually.
This allows for better composability; as of now, a route change re-renders the whole page. This is not always desired. Sometimes only a certain part of the page should be replaced. An example are Bootstrap pages which are usually composed of a header, body and a footer. There it makes sense to update only the body upon page change. Thanks to channels, the header does not even have to be static. It could reside in an
object
providing channels which pages could send data to.Instead of reloading the whole page, the page is constantly getting notified about changing argument(s). As channels already provide
unique
, this should be easy to implement. Then, it only re-renders those parts which are actually related to the changed argument.I guess, it would be hard to come up with a solution that doesn't make use of macros even if were to use Shapeless.
In general, the design comes close to what Spray already does and I'd suggest we take some inspiration from there: https://github.com/spray/spray/blob/master/spray-routing/src/main/scala/spray/routing/PathMatcher.scala
A similar concept can be found in this Haskell library: http://hackage.haskell.org/package/web-routes-boomerang-0.28.3/docs/Web-Routes-Boomerang.html
The text was updated successfully, but these errors were encountered: