Created
August 16, 2017 16:08
-
-
Save ccnokes/8e7dd239deae3b65231a76b8948a57f8 to your computer and use it in GitHub Desktop.
A simple store thing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { EventEmitter } from 'events'; | |
const enum Actions { | |
get, | |
set, | |
delete | |
} | |
export class Store extends EventEmitter { | |
private data = new Map<string, any>(); | |
set(key: string, val: any) { | |
this.data.set(key, val); | |
this.emit(`set`, { type: Actions.set, val, key }); | |
} | |
// TODO get, delete, has, etc | |
} | |
export const store = new Store(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment