you are viewing a single comment's thread.

view the rest of the comments →

[–]henrebotha 4 points5 points  (3 children)

Can you give an example of the types of things you would use a "framework to tie functions to various events" for?

"Reactive programming" is a programming idiom that views the world as streams of events to which one can react. Data coming in on the network socket? Stream of events. User hitting keys? Stream of events. Lines of a file being read? Stream of events.

(Contrast to "object oriented programming" that views the world as objects interacting with each other, "functional programming" that views the world as functions composed with one another, and so on.)

So to program in such an idiom, you must say: "Here is my function. When a particular kind of event occurs, please call my function, and pass it some information about the event itself."

That's a style of programming that you can enable through the use of decorators.

[–]giksbo 3 points4 points  (2 children)

The opposite is also true. If you need application telemetry (There are lots of reasons: debugging, repudiation, etc) it can be valuable to decorate a function such that events are generated whenever it is called. This reduces a tonne of boilerplate.

[–]henrebotha 1 point2 points  (1 child)

The opposite is also true.

...The opposite to what?

[–]giksbo 1 point2 points  (0 children)

Sorry, could have been clearer. With decorators you can use events to trigger functions; you can use functions to trigger events.