Fork me on GitHub
#keechma
<
2018-01-11
>
sooheon04:01:34

@mihaelkonjevic I’m looking for the idiomatic way to encode params in URL. How does this look for an on-click handler?

#(ui/redirect
  ctx
  (merge (:data @(ui/current-route ctx))
         {:dates %2}))

mihaelkonjevic07:01:00

Good, that’s how it was meant to be used. If you have a link element you can use ui/url which will return the string that can be used as the href attribute

sooheon07:01:55

Yep. And I noticed there is also a pipeline/redirect!--you thought of everything :)

sooheon07:01:11

About ui/url: if I’m using the :history router, [:a] links cause a full-on reload. I know libs like accountant (https://github.com/venantius/accountant) short circuit this reload for you--are you thinking of adding something like this to keechma?

mihaelkonjevic07:01:33

Hm, that should be short circuited. History router should add another component around the whole app which catches the clicks. I’ll check today if something broke

mihaelkonjevic07:01:58

@sooheon If you pull and run this example https://github.com/keechma/example-color-panels do you also see the bug where history router causes page reload? I’ve just tried it and it seems to be working correctly for me

sooheon07:01:26

That example works fine. But the links are only for route param color (i.e. they are after the ?). The links I have are route level links (just after /, before params).

mihaelkonjevic08:01:11

That shouldn’t matter, so it might be a bug. I’ll double check today and let you know

sooheon08:01:31

OK. I can kind-of reproduce it if I add routes key in history-app-definition: :routes [":page"] and another link: [:a {:href (ui/url ctx {:page "foobar"})} "Will Reload"]

sooheon08:01:51

It appears to work, but after a bit of clicking around it reloads and shows the figwheel error page

sooheon08:01:04

Definitely weird, it might just have to do with how I set up my app.

sooheon08:01:23

I could put it up on github if you have the time to look at it?

mihaelkonjevic08:01:47

Yes, please do

sooheon08:01:47

ok will ping once I do so

sooheon09:01:16

@mihaelkonjevic please take a look at the app when you can :)

mjmeintjes10:01:17

@mihaelkonjevic I was just about to ask for the ability to modify the route before passing it to params functions, but looking at the commit history I see you just added that - route processors. Thanks for that.

mihaelkonjevic10:01:16

@mjmeintjes yes, I’m not sure if it’s released yet. I can push a new release today if needed

mjmeintjes10:01:36

It's not urgent, but I've noticed that a lot of my code is basically just pulling out specific data from the route. I currently have a route namespace with functions for doing that, but having the route pre-processed will clean it up a lot. However I probably won't work on that in the next week or so, so no rush.

mjmeintjes10:01:23

I'm working on a new project that will require server side rendering. I noticed that there is an example using Macchiato. Have you used Macchiato in production yet? I'm trying to figure out if it is stable enough to use in a real world app.

mihaelkonjevic10:01:41

We had an rnd project built with macchiato and I didn’t have any problems with it. In my company we’re using elixir on backend so we don’t have any real production experience with it

sooheon10:01:59

@mihaelkonjevic I have a question about routing and dataloader. I think of the route as the entrypoint to the app state, so I hooked up a date-range filter in my dashboard to the route (it would put ?dates=2017-01-01,2018-01-01 or something). This allows me to declaratively load data with the dataloader, but it also causes a lot of extra navigation when I press the back button. Rather than going to the last page, it just goes to the last set of params. Is there a way to “squish together” all navigations where only the params have changed, not the route?

mihaelkonjevic10:01:35

@sooheon no, not really. It might be possible (but I’d have to implement it) with the history router, but not with the hashchange one. You could also store those filters in app db instead of the url and then manually retrigger the dataloader. I can make you an example of that if you’re interested

sooheon10:01:36

Yes I am interested. I’m trying that method now, and I’m getting mixed up in when dataloaders/controllers retrigger/clean-up data.

mihaelkonjevic10:01:10

I’ll make you an example in an hour or so

sooheon10:01:16

Thank you!

mihaelkonjevic11:01:25

You can manually call (dataloader-controller/run-dataloader!) function from a pipeline after you manually set the value of a datasource

mihaelkonjevic11:01:53

The whole idea of dataloader is that it helps you when possible, but leaves you in control for cases that are not covered by the dataloader