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

Applying blueprints #6

Closed samuelsimoes closed 9 years ago

samuelsimoes commented 9 years ago

Remeber: blueprint are the new name that we going to call the extensions to stores (https://github.com/fluxo-js/fluxo/pull/4#issuecomment-144563805).

Today we have:

var jonh = Fluxo.ObjectStore.create({ 
  data: { name: "John Doe" } 
});

var people = Fluxo.CollectionStore.create({
  stores: [{ name: "John Doe" }],

  store: { ...custom behavior to children store... }
});

Notice the ObjectStore.create today is something like Fluxo.extend(myBlueprint, Fluxo.ObjectStore), so we need place our initial data on data property of our object that will goes be enhanced, but on the CollectionStore we pass the initial data to children stores without the data property because the blueprint application for children stores occours using the store property of collection store.

So, I was thinking to normalize this making the first argument of ObjectStore.create be the attributes of the new created stores and the second forward argument be the blueprints. Like this:

var john = Fluxo.ObjectStore.create({ name: "John Doe" }, {
  sayYourName: function () {
    alert(this.data.name);
  }
});
samuelsimoes commented 9 years ago

Changing plans https://github.com/fluxo-js/fluxo/pull/10