Skip to content

Instantly share code, notes, and snippets.

@teddyzeenny
Created August 7, 2013 18:20
Show Gist options
  • Save teddyzeenny/6176897 to your computer and use it in GitHub Desktop.
Save teddyzeenny/6176897 to your computer and use it in GitHub Desktop.
Data Adapter API - option 2
// Disadvantage: releasing model types will clear all observers
// irrespective of how many times getModelTypes was requested
// or who made the request
getModelTypes: function(target, typesReceived, typeAdded, typeUpdated, typeRemoved) {
// code to fetch types ...
// ...
// call typesReceived and pass fetched types
typesReceived.call(target, types);
// .. setup array observers to call typeAdded, typeUpdated, and typeRemoved on changes
},
releaseModelTypes: function() {
//.. code to clear all observers
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment