Skip to content

Instantly share code, notes, and snippets.

@ccnokes
Created August 16, 2017 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ccnokes/8e7dd239deae3b65231a76b8948a57f8 to your computer and use it in GitHub Desktop.
Save ccnokes/8e7dd239deae3b65231a76b8948a57f8 to your computer and use it in GitHub Desktop.
A simple store thing
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