Add basic concepts for event bus, and implement in request and model
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
31
src/orm/model/events/ModelEvent.ts
Normal file
31
src/orm/model/events/ModelEvent.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user