Skip to content

Instantly share code, notes, and snippets.

@avdi
Created October 5, 2012 20:38
Show Gist options
  • Save avdi/3842243 to your computer and use it in GitHub Desktop.
Save avdi/3842243 to your computer and use it in GitHub Desktop.
Observer pattern terminology

When it comes to the Observer pattern, there are a number of related, overlapping terms used by different codebases. Off the top of my head:

  • Observer/Observable/Subject
  • Listener/Listenable
  • Event/Event source/Event sink/Event handler
  • Hook/Callback
  • Subscriber/Subscribable
  • "Firing" vs. "Triggering" vs "Notifying" vs "Executing"

Which of these do consider to be synonymous?

Of terms that are synonymous, which do you prefer to use in your programs?

Of terms that are not synonymous, what semantic differences do the different terms imply to you?

@kevinrutherford
Copy link

Observer and Listener seem closely coupled with the source, compared to Publish/Subscribe and Notify, which both feel quite decoupled from the source (of events/notifications). So I will ATTACH a Listener directly to an object, but Subscribe to events/notifications from who-knows-where.

@gicappa
Copy link

gicappa commented Oct 6, 2012

@kevinrutherford +1 this is a good point: in general you can publish/subscribe to a "topic/queue/board" that is a more general concept than listen/observer an object.

@josemotanet
Copy link

I've seen pub/sub as in — publish / subscribe — somewhere when developing Javascript a time ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment