Fork me on GitHub

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?


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)


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


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


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?


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


so yeah, it’s designed to work like that


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.


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


these two diagrams show difference between the route change and command


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


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


Yea, I like that principle.


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


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


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


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


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


otherwise I’d just change the url from the component


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