Add action statistics
This commit is contained in:
23
src/State/StatisticsState.ts
Normal file
23
src/State/StatisticsState.ts
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user