Created
August 17, 2015 17:53
-
-
Save odoe/73d1e9f19cf2a52c9c41 to your computer and use it in GitHub Desktop.
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
/// <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