adonisjs-livewire
Version:
A front-end framework for AdonisJS
20 lines (19 loc) • 508 B
JavaScript
import { Decorator } from '../support_decorators/decorator.js';
export default class Computed extends Decorator {
name;
method;
constructor(name, method) {
super();
this.name = name;
this.method = method;
}
async render() {
if (typeof this.component[this.method] !== 'function') {
return;
}
let value = await this.component[this.method]();
this.component.view.share({
[this.name]: value,
});
}
}