Type of the objects to compare.
class Entity implements Equatable<Entity> {
private id: number;
private name: string;
private mail: string;
constructor(id: number, name: string, mail: string) {
this.id = id;
this.name = name;
this.mail = mail;
}
equals(rhs: Entity) {
return rhs !== undefined && this.id === rhs.id;
}
}
const user = DatabaseAPI.getById(1);
// ... some code
// This creates a new user instance
const sameUser = DatabaseAPI.getById(1);
user === sameUser; // => false
user.equals(sameUser) // => true
Generated using TypeDoc
An interface for equatable objects of the same type. They are checked for equality via a special method
equals
.