ModelFactory: add hasComponent method
This commit is contained in:
parent
ead3c8ce1e
commit
bb8b44b5a3
@ -32,6 +32,10 @@ export default class ModelFactory<M extends Model> {
|
||||
this.components.push(modelComponentFactory);
|
||||
}
|
||||
|
||||
public hasComponent(modelComponentFactory: ModelComponentFactory<M>): boolean {
|
||||
return !!this.components.find(c => c === modelComponentFactory);
|
||||
}
|
||||
|
||||
public create(data: Pick<M, keyof M>, isNewModel: boolean): M {
|
||||
const model = new this.modelType(this as unknown as ModelFactory<never>, isNewModel);
|
||||
for (const component of this.components) {
|
||||
|
Loading…
Reference in New Issue
Block a user