Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save afuggini/8e1859d20f86d35c6ef6 to your computer and use it in GitHub Desktop.
Save afuggini/8e1859d20f86d35c6ef6 to your computer and use it in GitHub Desktop.
.factory('genericCollectionFactory',function(){
function Collection() {
var _items = [];
function get () {
return _items;
}
function add (item) {
_items.push(item);
}
function empty () {
// _items = []; // BEWARE!
_items.length = 0;
}
return {
get: get,
add: add,
empty: empty
};
}
return {
create: function () {
return new Collection();
}
};
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment