Below is the code snippet for different classes describing models and emitters:
export class Findbyobjectidlatest {
onChanged = new EventEmitter<Ifindbyobjectidlatest>();
model = <Ifindbyobjectidlatest>{ pagesize: 10 };
emit() {
this.onChanged.emit(this.model);
}
}
export class Findbycadnum {
onChanged = new EventEmitter<Ifindbycadnum>();
model = <Ifindbycadnum>{ pagesize: 10 };
emit() {
this.onChanged.emit(this.model);
}
}
export class Findbycadastnumber {
onChanged = new EventEmitter<Ifindbycadastnumber>();
model = <Ifindbycadastnumber>{ pagesize: 10 };
emit() {
this.onChanged.emit(this.model);
}
}
I am looking for suggestions on how to refactor this code as these classes are quite similar.
In addition, I have a repository class defined as:
class RepositoryModel {
findbyobjectidlatest = new Findbyobjectidlatest();
findbycadnum = new Findbycadnum();
findbycadastnumber = new Findbycadastnumber();
}
To utilize this repository class, you can create an instance like this:
const repositoryModel = new RepositoryModel();
repositoryModel.findbyobjectidlatest.onChanged().pipe().subscribe();
And so forth.