The Model
What is the Model?
In alt-seven, the model refers to two separate things. First there is the a7.model component that interacts directly wit alt-seven based applications. Second, there is a model implementation, which could be any model object that exposes the required methods (listed below from a7.model) necessary to meet the contract for what alt-seven expects in a model. When the framework was built, it used its own internal model, a7.Components.Model, as the implementation of the model. It also allowed the use of the model from the open source gadget-ui library, but any model that meets the contract for the methods below should work. Programmers can choose to implement their own model if it serves their needs.
The alt-seven model includes a variety of experimental features that are not currently exposed but may be included in future releases of the framework.
destroy : function(){
return _methods[ "destroy" ].apply( _model, arguments );
},
get : function(){
return _methods[ "get" ].apply( _model, arguments );
},
set : function(){
return _methods[ "set" ].apply( _model, arguments );
},
exists : function(){
return _methods[ "exists" ].apply( _model, arguments );
},
Working with the Model
As it stands today, the four methods listed above are the only methods exposed in a7.model, so implementation is very simple.
// get the current user from the model
let user = a7.model.get("user")
// set the current user into the model
a7.model.set( "user", user )
// check if a key exists in the model
let userExists = a7.model.exists("user")
// delete the key from the model
a7.model.delete("user")
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.