Closed samuelsimoes closed 8 years ago
Some conversation about this also on https://github.com/fluxo-js/fluxo/issues/20#issuecomment-182044996.
Would be nice :shipit:
So, summarizing the ideas of the other issue (#20) this would be like this:
class Person extends Fluxo.ObjectStore {
static attributes = {
author: {
defaultValue: {},
required: true,
parser: function (value) { return new Fluxo.ObjectStore(value); },
dump: function (value) { return value.data.id; }
}
age: {
defaultValue: 0,
required: true,
parser: function (value) { return parseInt(value, 10); }
},
name: { required: true }
};
}
Are you ok with this, @sobrinho?
The required
there is only a hint, not a validation (like Backbone, for example).
PR included.
Today, without default attributes I can't easily find what attributes a store needs/uses. To address this issue, ReactJS has the propTypes key on the components. It's very useful because on a glance I can recognize all component's attributes dependencies.
What do you think about this on Fluxo?