Make settings as a clean architecture
This commit is contained in:
parent
e76ca380f7
commit
bacf83a320
16 changed files with 223 additions and 196 deletions
24
src/content/usecases/SettingUseCase.ts
Normal file
24
src/content/usecases/SettingUseCase.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import SettingRepository, { SettingRepositoryImpl }
|
||||
from '../repositories/SettingRepository';
|
||||
import SettingClient, { SettingClientImpl } from '../client/SettingClient';
|
||||
import Settings from '../../shared/Settings';
|
||||
|
||||
export default class SettingUseCase {
|
||||
private repository: SettingRepository;
|
||||
|
||||
private client: SettingClient;
|
||||
|
||||
constructor({
|
||||
repository = new SettingRepositoryImpl(),
|
||||
client = new SettingClientImpl(),
|
||||
} = {}) {
|
||||
this.repository = repository;
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
async reload(): Promise<Settings> {
|
||||
let settings = await this.client.load();
|
||||
this.repository.set(settings);
|
||||
return settings;
|
||||
}
|
||||
}
|
Reference in a new issue