Fork me on GitHub
#keechma
<
2016-04-05
>
roberto03:04:30

is there a way to trigger a message from within a Controller’s params function?

mihaelkonjevic07:04:50

@roberto you could, but it would go to the wrong "instance" of the controller. Params function is called before the controller is started. Why not calling it from the start function?

roberto13:04:53

I probably don’t understand the lifecycle of a component.

roberto13:04:35

the start function only gets called once, right?

roberto13:04:47

while the params function gets called everytime the url changes?

roberto13:04:32

I have a component that is already rendered, and want to modify it everytime the url changes.

mihaelkonjevic13:04:28

you get the route-changed command sent through the in-chan everytime route changes

roberto13:04:09

that is very helpful

roberto13:04:47

I didn’t think to look inside that file. Didn’t understand its purpose

mihaelkonjevic13:04:20

it basically clears the stale data from the entity db on each route change

roberto13:04:10

so you can have a controller that is not associated with any component

mihaelkonjevic13:04:17

controllers operate on the route

mihaelkonjevic13:04:25

they don't really care about components

roberto13:04:51

okay, I think it is kind of clicking. So, the only way a component can be linked to a controller is via its topic. And it can only be associated to one topic, hence only to one controller.

roberto13:04:29

but that doesn’t restrict it from sending commands to other controllers using the send-command, right?

mihaelkonjevic13:04:52

it does because the component's send command will always send it on it's one topic

mihaelkonjevic13:04:59

but if you need to broadcast the message

mihaelkonjevic13:04:44

theoretically you could add a transducer

mihaelkonjevic13:04:47

on teh command channel

mihaelkonjevic13:04:51

and duplicate commands

roberto13:04:54

ah, so change the url if you want to broadcast?

mihaelkonjevic13:04:55

to various topics

roberto13:04:06

okay, that sounds cleaner

mihaelkonjevic13:04:10

also, controllers can send commands to other controllers

mihaelkonjevic13:04:25

so you could have a controller that relays commands from the component to other controllers

roberto13:04:06

cool, yeah I did that with a search component

roberto13:04:15

but I don’t think I understood what I was doing simple_smile

roberto13:04:37

it is becoming clearer now.