You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lib/src/orm/model/events/ModelEvent.ts

32 lines
688 B

import {Model} from '../Model'
import {Event} from '../../../event/Event'
import {JSONState} from '../../../util'
/**
* Base class for events that concern an instance of a model.
*/
export abstract class ModelEvent<T extends Model<T>> extends Event {
/**
* The instance of the model.
*/
public instance!: T
constructor(
instance?: T,
) {
super()
if ( instance ) {
this.instance = instance
}
}
// TODO implement serialization here
dehydrate(): Promise<JSONState> {
return Promise.resolve({})
}
rehydrate(/* state: JSONState */): void | Promise<void> {
return undefined
}
}