Skip to content

Instantly share code, notes, and snippets.

@amb26
Created September 26, 2013 19:15
Show Gist options
  • Save amb26/6719152 to your computer and use it in GitHub Desktop.
Save amb26/6719152 to your computer and use it in GitHub Desktop.
Current base model hierarchy
/** MODEL COMPONENT HIERARCHY **/
fluid.initSimpleModel = function (that, optionsModel) {
return that.model = optionsModel || {};
};
fluid.initRelayModel = function (that, optionsModel, applier) {
return optionsModel || {};
};
fluid.establishModelRelay = function (that, model, optionsModel, optionsML, applier) {
// build up here
fluid.mergeModelListeners(that, optionsML);
applier.initModelEvent();
};
// Grade common to "old" and "new" model components
fluid.defaults("fluid.commonModelComponent", {
gradeNames: ["fluid.littleComponent", "autoInit"],
mergePolicy: {
modelListeners: fluid.makeMergeListenersPolicy(fluid.arrayConcatPolicy)
}
});
fluid.defaults("fluid.modelComponent", {
gradeNames: ["fluid.commonModelComponent", "autoInit"],
members: {
model: "@expand:fluid.initSimpleModel({that}, {that}.options.model)",
applier: "@expand:fluid.makeChangeApplier({that}.model, {that}.options.changeApplierOptions)",
modelListeners: "@expand:fluid.mergeModelListeners({that}, {that}.options.modelListeners)"
},
mergePolicy: {
model: "preserve"
}
});
fluid.defaults("fluid.modelRelayComponent", {
gradeNames: ["fluid.commonModelComponent", "fluid.eventedComponent", "autoInit"],
members: {
model: "@expand:fluid.initRelayModel({that}, {that}.options.model, {that}.applier)",
applier: "@expand:fluid.makeHolderChangeApplier({that}, {that}.options.changeApplierOptions)",
modelRelay: "@expand:fluid.establishModelRelay({that}, {that}.model, {that}.options.model, {that}.options.modelListeners, {that}.applier)"
},
mergePolicy: {
modelRelay: fluid.arrayConcatPolicy
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment