adonisjs-livewire
Version:
A front-end framework for AdonisJS
46 lines (45 loc) • 1.11 kB
JavaScript
export class Synth {
context;
path;
app;
constructor(context, path, app) {
this.context = context;
this.path = path;
this.app = app;
}
static getKey() {
// @ts-ignore
if (!this.key) {
throw new Error('You need to define static $key property on: ' + this.name);
}
// @ts-ignore
return this.key;
}
getKey() {
// @ts-ignore
if (!this.constructor.key) {
throw new Error('You need to define static $key property on: ' + this.constructor.name);
}
// @ts-ignore
return this.constructor.key;
}
static match(target) {
return false;
}
static matchByType(type) {
return false;
}
async dehydrate(target, hydrateChild) {
return [target, {}];
}
async hydrate(value, meta, hydrateChild) {
return value;
}
// abstract hydrateFromType(type, value)
get(target, key) {
if (Array.isArray(target)) {
return target[key] ?? null;
}
return target[key];
}
}