keechma

Keechma stack. Mention @U050986L9 or @U2J1PHYNM if you have any questions
bocaj 2016-07-05T17:00:51.000217Z

This seems like a bad pattern, but what if you change the url from the component using (ui/url this {:query "where is waldo"})? that's more coupled than sending a command, right?

mihaelkonjevic 2016-07-05T17:02:00.000218Z

I don’t really think it’s a bad patter. URL is always there, and you can control how the URL is formatted from the outside. You just persist part of the state in the URL (so you can recreate some stuff on reload)

mihaelkonjevic 2016-07-05T17:02:24.000219Z

actually URLs are the most important part in Keechma because they drive controllers, so use them freely 🙂

mihaelkonjevic 2016-07-05T17:02:47.000220Z

the controllers are the one who assign the meaning to the URL data, so it’s already somewhat decoupled

bocaj 2016-07-05T17:04:02.000221Z

I see. So it's possible and "OK", but is this how you designed the system to be used? Or, do use commands from components as a rule of thumb?

mihaelkonjevic 2016-07-05T17:05:35.000222Z

so, here’s how I see it: URL change is “tectonic” change for the state. It might cause a lot of stuff happening at once. That’s why controllers react to urls and are getting started or stopped. Commands are for gradual changes between the tectonic changes, that’s why started controllers can listen to commands. But controllers are started only when they care about the data in the URL

mihaelkonjevic 2016-07-05T17:05:54.000223Z

so yeah, it’s designed to work like that

bocaj 2016-07-05T17:06:57.000224Z

Ok. So when you change a url and every controller listens for the url change, then a lot of stuff, potentially, will happen on url change.

bocaj 2016-07-05T17:07:45.000225Z

But, if you're sending commands off to a topic, then you can very clearly see what is happening. Fewer effects.

mihaelkonjevic 2016-07-05T17:08:03.000226Z

these two diagrams show difference between the route change and command

mihaelkonjevic 2016-07-05T17:08:05.000227Z

https://keechma.com/route_change.svg

mihaelkonjevic 2016-07-05T17:08:11.000228Z

https://keechma.com/command_sent.svg

mihaelkonjevic 2016-07-05T17:09:39.000229Z

it really depends on you what stuff you put in the URL, but my philosophy is to put in everything I need to recreate the app state on reload

mihaelkonjevic 2016-07-05T17:09:59.000230Z

that way you can reason about your app as if every route change is basically page reload.

bocaj 2016-07-05T17:11:03.000231Z

Yea, I like that principle.

bocaj 2016-07-05T17:12:36.000232Z

So, the way I see it, using a command, it's a good idea for the controller to update the url. For example, /page?q=a+query

bocaj 2016-07-05T17:13:56.000233Z

Or, for the component to change the url, and the controllers handle that change.

bocaj 2016-07-05T17:15:48.000234Z

Hmm, but if the controller is redirecting to a url anyways, it's a design decision regarding which option to take

mihaelkonjevic 2016-07-05T17:16:26.000235Z

I would use controller to change the url only if there is some preprocessing involved

mihaelkonjevic 2016-07-05T17:16:38.000236Z

for instance if you have a live search, and you want to wait until user is not typing for 200ms

mihaelkonjevic 2016-07-05T17:16:50.000238Z

otherwise I’d just change the url from the component

bocaj 2016-07-05T17:17:15.000239Z

That is a perfect example. Just what I'm doing right now.