Skip to content

Instantly share code, notes, and snippets.

@teddyzeenny
Last active December 20, 2015 18:38
Show Gist options
  • Save teddyzeenny/6176786 to your computer and use it in GitHub Desktop.
Save teddyzeenny/6176786 to your computer and use it in GitHub Desktop.
Data Adapter API - option 1
// Advantage: the adapter can be used by multiple tools at the same time and every `getModelTypes` request is isolated.
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
var releaseMethod = function() {
//.. code to clear all observers
}
return releaseMethod;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment