fluxo-js / fluxo

Fluxo is a simple, lightweight (~300LOC) and dependency free data infrastructure lib based on Facebook Flux and Backbone.js. It's compatible with React.js, but you can use with whatever you want to the view/component layer.
15 stars 3 forks source link

Quick dumb collections #43

Closed samuelsimoes closed 8 years ago

samuelsimoes commented 8 years ago

Sometimes we just want a dumb collection that parses it's children stores with some object store class without the need of declare this dumb collection class just to declare the children store class, like:

// Person class code omited
class People extends Fluxo.CollectionStore {
  static store = Person;
}

Would be nice if Fluxo could understand something like this:

var people = new Fluxo.CollectionStore([...], { store: Person });
people.addStore({ name: "Samuel" });
people.stores[0] // => a Person class instance.
sobrinho commented 8 years ago

As we spoke on Skype, we need a third argument as options to not pollute or mutate the data, i.e.:

var people = new Fluxo.CollectionStore(null, null, { store: Person });
people.addStore({ name: "Samuel" });
people.stores[0] // => a Person class instance.
samuelsimoes commented 8 years ago

👌 totally agree.