Add basic concepts for event bus, and implement in request and model
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-06-04 01:03:31 -05:00
parent dab3d006c8
commit 61731c4ebd
20 changed files with 375 additions and 52 deletions

View 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
}
}