Mark set/jump as a clean architecture

This commit is contained in:
Shin'ya Ueoka 2019-05-11 16:38:08 +09:00
parent ebfb172520
commit c6288f19d9
16 changed files with 316 additions and 137 deletions

View file

@ -0,0 +1,25 @@
import Mark from '../domains/Mark';
export default interface MarkRepository {
set(key: string, mark: Mark): void;
get(key: string): Mark | null;
// eslint-disable-next-line semi
}
const saved: {[key: string]: Mark} = {};
export class MarkRepositoryImpl implements MarkRepository {
set(key: string, mark: Mark): void {
saved[key] = mark;
}
get(key: string): Mark | null {
let v = saved[key];
if (!v) {
return null;
}
return { ...v };
}
}