add documentation in README, examples, and tests
Closed this issue · 7 comments
I'm looking at how y'all are using the routing in the slamdata app and trying to piece where it all comes together. I can see that the routes are defined like this and this, and this is where the routing function gets called. I can't quite figure out it all ties in here though.
I'd definitely like to use this in an app I am planning to build, and would be happy to write up a good introductory tutorial in the process :D I think if I could just get a little nudge in how the routes tie in to the halogen components then I'd be set.
Hey Matt, that'd be awesome! You can ping @cryogenian in the gitter.im/slamdata/slamdata chat room, and he should be able to give you a nudge or two. 😄
Ok! I've got something worked up. The draft post is here. I'd appreciate any feedback or input y'all might have.
One thing I'm definitely curious about is if there's a better way to write the redirects function for a parent component:
redirects :: forall eff. Driver QueryP eff
-> Maybe Routes
-> Routes
-> Aff (Effects eff) Unit
redirects driver _ Home =
driver (Coproduct (Left (action (Goto Home))))
redirects driver _ Profile =
driver (Coproduct (Left (action (Goto Profile))))
redirects driver _ (Sessions view) =
driver (Coproduct (Left (action (Goto (Sessions view)))))
It's not too bad with a driver <<< Coproduct <<< Left <<< action <<< Goto, but it feels like there should be a less direct way to encode that.
You can use left from Data.Functor.Coproduct to avoid the need for Coproduct (Left ..., but apart from that I think you have to do what you have here.
@parsonsmatt Wow, nice work on that post!
@garyb I feel like maybe prisms and purescript-totally should help here. Albeit it'd probably be more code unless you have that type of matching in multiple places.
Awesome, left is an improvement 😄