Why no observer patterns?

The observer pattern is really quite handy:
“Hey, you, the dude responsible for managing Josh’s twitter posts! Let me know when he posts something new! My address is…”

That’s basically it. It works in Cocoa, it works in SproutCore (Javascript), it works in Rails.. Why has it never been taken to a wider scale?? I understand that pushing to users is difficult due to the “statelessness” of HTTP, but “push”ing between servers with static IP/Hostnames should be decently trivial.

REST, JSON, SSL, toss out any number of acronyms you want. It’s doable in a number of different ways. So why isn’t it common? Why can’t I subscribe to your blog and have it notify me when you make a new post? Forcing me to poll your RSS feed periodically to see if you’ve made a new post is, shall we say, fucking backwards and wrong!!

So what are the real challenges here?

  1. Callback address. What if a registered observer changes their callback URL? How do we address them?
  2. How do we authorize changes? Must research OpenID/OAuth and see if there are systems that might work for this.
  3. Sufficiently extensible and user-definable. No locking the user profile into ONLY having fields like “favorite pet” and “smoker y/n”. No limiting the language used.

What might this look like?? If I (joshproehl.com) want to obsevre events at daedalusdreams.com I could send this:


http://daedalusdreams.com/observer/create
POST
{
model:blogpost
callback:http://joshproehl.com/listener/
}

And then when daedalusdreams.com makes a change to the blogposts it would know to send this:


http://joshproehl.com/listener/
POST
{
source:http://daedalusdreams.com/
model:blogpost;
sourceURL:http://daedadalusdreams.com/blog/5
}

I’m having trouble visualizing both exactly how this would work, and why it might not. I think it may be time to start diagramming some things out.

Continue reading in Part 2