montagejs / collections

This package contains JavaScript implementations of common data structures with idiomatic interfaces.
http://www.collectionsjs.com
Other
2.09k stars 185 forks source link

override data source #103

Closed pocketmax closed 9 years ago

pocketmax commented 9 years ago

Instead of using a native object to store items, you could point the collection to an alternative data source instead. Like a memory store like this one...

http://jxcore.com/docs/jxcore-store.html

var List = require("collections/list");
List.source = jxcore.store;
var list = new List([1,2,3]);

This way, all the values are stored in the jxcore.store but accessed via the list collection. Almost like an adapter/wrapper pattern.

kriskowal commented 9 years ago

Collections provides quite lot of generics that would enable one to create a proxy for a jxcore-store, but providing such an adapter is outside the scope of the collections project, and well within the scope of a small package that depends upon and combines both.