Skip to content

Instantly share code, notes, and snippets.

@airportyh
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save airportyh/9666135 to your computer and use it in GitHub Desktop.
Save airportyh/9666135 to your computer and use it in GitHub Desktop.

Proposed New Adapter API

Constructor

new Adapter()

Methods

  • subscribe(obj, property, fn) - listen for when an object property changes
  • unsubscribe(obj, property, fn) - unsubscribe a property change handler
  • unsubscribeAll(obj) - unsubscribe all events on object
  • get(obj, property) - get obj's property
  • set(obj, property) - set obj's property
  • collectionForEach(collection, fn) - iterate a collection
  • collectionSubscribe(collection, fn) - listen for when a collection changes
  • collectionUnsubscribe(collection, fn) - unlisten for collection change event
@defunctzombie
Copy link

Not a fan of passing the object into the adapter. I like the idea of just creating the adapter and having it track with the model it is adapting for.

I think the array adapter (I wouldn't call it collection cause that is just longer and not javascript) could be a separate option potentially. The two adapters really are very different and I could imagine users wanting to use two different ones for those. Would that work for backbone usecase, to have two?

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