Add action statistics

This commit is contained in:
2020-04-27 21:14:46 +03:00
parent 8807c2b070
commit 6ce839f4be
4 changed files with 58 additions and 3 deletions

View File

@ -0,0 +1,23 @@
import { DataStorage } from '../DataStorage';
import { ActionStatistics } from '../Statistics';
const NAMESPACE = 'statistics.v1';
const ACTION_STATISTICS_KEY = 'actions';
export class StatisticsState {
private storage: DataStorage;
constructor() {
this.storage = new DataStorage(NAMESPACE);
}
getActionStatistics(): ActionStatistics {
return this.storage.getTyped<ActionStatistics>(ACTION_STATISTICS_KEY, {
factory: () => ({}),
});
}
setActionStatistics(statistics: ActionStatistics): void {
this.storage.set(ACTION_STATISTICS_KEY, statistics);
}
}