I have written little code with jQuery. The one thing I first noticed is that it “reverses” the logic between “caller” and “action”. What I mean by that is instead of having an html button which points to a javascript function when clicked, you now have a javascript function that listens to the click events of the desired button. The extended use of this framework makes me think that for some reason is more desirable than the first approach.
Is there any particular reason for this ?
Are there any similar patterns on other languages ex. Python ?
For example is there a way to make a function in Python that “listens” on the change of a certain variable x and then executes ?
[EDIT]
As I commented, I can’t figure out why “B listens to events happening on A” is more favorable of “A tells B that something happened to itself”