N
Size: a a a
N
VK
SK
N
VL
VK
VL
SK
VL
Some {
isSome:
boolean;
}
interface SomeRepository {
findOne(): Some;
}
class Kek {
constructor(
private readonly someRepository:
SomeRepository) {}
doSomeLogic() {
const some =
this.someRepository.findOne();
console.log('flexing with some');
}
}
class PostgresRepository
implements SomeRepository {
findOne(): Some {
console.log('Im pg');
return undefined;
}
}
class SQLiteRepository
implements SomeRepository {
findOne(): Some {
console.log('Im sqlite');
return undefined;
}
}
const someRepoFactory = ():
SomeRepository => {
return mode === 'prod' ?
new PostgresRepository() :
new SQLiteRepository();
};
const mode:
string = 'test';
new Kek(
someRepoFactory())
N
АП
VK
VK
VL
N
VL
N
VL