Skip to content

Instantly share code, notes, and snippets.

@odoe
Created August 17, 2015 17:53
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 odoe/73d1e9f19cf2a52c9c41 to your computer and use it in GitHub Desktop.
Save odoe/73d1e9f19cf2a52c9c41 to your computer and use it in GitHub Desktop.
/// <reference path="../../../dojo.d.ts"/>
/// <amd-dependency path="dojo/Stateful" name="Stateful"/>
/// <amd-dependency path="dojo/topic" name="topic"/>
import { ICoords } from '../interfaces.d';
declare var Stateful: dojo.Stateful;
declare var topic: dojo.topic;
class Store extends dojo.Stateful implements ICoords {
x = 0
y = 0
};
// http://www.anujgakhar.com/2013/08/29/singletons-in-dojo/
if (!_instance) {
var _instance: Store = new Store();
topic.subscribe('UPDATE-XY', (data: ICoords) => {
_instance.set('x', data.x);
_instance.set('y', data.y);
});
}
export default _instance;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment