-
-
Notifications
You must be signed in to change notification settings - Fork 5
Extend Class
StefansArya edited this page Jan 7, 2021
·
2 revisions
This feature also available for component.
First you must define your class before initializing the model
class MyClass{
// This will be called when the model scope was initialized
// and before calling `My.init`
static construct(){
// this.abc === 1
this.hello = 2;
}
method(number){
console.warn(number + " + 1 = ", number + 1);
}
}
Or define your class with function so you can also define the model first
function MyClass(){}
MyClass.construct = function(){
this.hello = 2;
};
MyClass.prototype.method = function(number){
console.warn(number + " + 1 = ", number + 1);
};
Define an model while extending our class.
sf.model('something', {extend: MyClass}, function(My){
My.abc = 1;
// Called after static construct on the class
My.init = function(){
// My.hello === 2
My.method();
}
My.method = function(){
console.log("2");
// You can also call method from the class with similar name
this.super(2);
}
});
- Framework
-
Installation
- Build Configuration
- Hot Reload
- Loader
- Model
-
Component
- Reserved Element
- Empty Shell
- Include external template
- Space
-
Views (Router)
- URI
- Static Template
- Language
- Element's query helper
- Events
- URL Request
- Window Extends