-
-
Save afuggini/8e1859d20f86d35c6ef6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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