[Coldbox 4.3.0] What is event in coldbox exactly?

Hi, I am new to Coldbox and just start one month in back end development. After I went through the documentation, I am still a little confused by “event” in coldbox.
What exactly it refers to? If I do event.setValue(“output”,“helloworld”), does it mean save a variable to the event?
What is the relationship between event and rc/prc? What is the difference between event.setValue and rc.somevariable=…?
(I am sorry if the question is too naive and the inconvenience caused)

Thanks a lot!


Hi Jiamin!

You can think of the event as a train that begins when you go to a URL in your app and ends once the final content is delivered to the browser. Along the way, the train has “stops”. It doesn’t actually STOP, but those stops have names, such as “onRenderStart”, “onRenderEnd”…each one signifies a milestone along the path from beginning to end. And by giving those milestones names, it allows you, the programmer, to do things at those points.

As to your other question about event.setValue, think of that as you putting passengers ON the train as it travels! In your example, you put a passenger on the event train named “output” with a value of “helloworld”. What that means, then, is that any of your other code can talk to the event train as it passes by and interact with the “output” passenger that you put on it.

As for RC verses PRC, think of THAT as a public train car that any of your code can access verses a very exclusive “private” train car that only certain aspects of your code is able to see and interact with.

I may not be completely accurate with my analogy, but I think it’s a good start on how to think about the event train! Choo choooooo!!!

Doug :0)

Hi, Doug! Thanks a lot for your explanation and your patience. It is very clear and I can even visualize the whole scene^ ^ I think it will help me a lot to my project, everything appears to be clearer.

Thank you!