My question is pretty simple: how is event-driven programming actually achieved?
To elaborate: I have a Rails application, every time a user makes a change on the website, the model writes that "change" to a text file (as JSON.)
What I'd like to do is hook an IRC bot to that "event." (the creation/modification of the text file.)
How is this done in general? It seems like it'd basically be an infinite loop. In pseudocode:
while (I'm Listening)
do
if (output.txt Is changed)
process("output.txt")
If this is how event-driven programming is achieved - how does it avoid locking up the CPU? As infinite loops have a tendency to do?
Edit- The IRC server/bot are hosted on a locally maintained box. The Rails application is hosted on a shared server. As of now, the only way I know for my IRC bot to communicate with the Rails app is via an HTTP request to the server (or something similar.) As I stated though, this question is really more general, as I'd like to garner a knowledge of event-driven programming in general.
I apologize if this question is impossibly simple, but my understanding of event driven programming consists of attaching pre-made event handlers to objects with jQuery; which really doesn't help when attaching an IRC bot [written in Ruby] to file I/O.
Thanks, Robbie