drawpad/js/State.js
2015-12-03 04:34:54 -05:00

25 lines
No EOL
473 B
JavaScript

'use strict';
/*
* Keeps global state properties like frames, current strokeColor etc.
*/
let singleton = Symbol();
let singletonEnforcer = Symbol();
class State {
constructor(enforcer, props) {
if(enforcer != singletonEnforcer) throw "Cannot construct singleton";
this.props=props;
}
static get instance() {
if(!this[singleton]) {
this[singleton] = new State(singletonEnforcer);
}
return this[singleton];
}
}
export default State