mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
46 lines
787 B
Plaintext
46 lines
787 B
Plaintext
class {
|
|
onCreate() {
|
|
this.record('create', arguments, this);
|
|
}
|
|
|
|
onRender(){
|
|
this.record('render', arguments, this);
|
|
}
|
|
|
|
onMount(){
|
|
this.record('mount', arguments, this);
|
|
}
|
|
|
|
onUpdate(){
|
|
this.record('update', arguments, this);
|
|
}
|
|
|
|
record(name, args, thisObj) {
|
|
this.hooks = this.hooks || (this.hooks = []);
|
|
|
|
this.hooks.push({
|
|
name: name,
|
|
args: args,
|
|
thisObject: thisObj
|
|
});
|
|
}
|
|
|
|
reset() {
|
|
this.hooks = null;
|
|
}
|
|
|
|
get hookNames() {
|
|
if (!this.hooks) {
|
|
return [];
|
|
}
|
|
|
|
return this.hooks.map(function(hook) {
|
|
return hook.name;
|
|
});
|
|
}
|
|
}
|
|
|
|
<div>
|
|
Hello <span.name>${input.name}</span>!
|
|
</div>
|