Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@davros85
Last active October 17, 2016 11:12
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 davros85/33b0558c20bba93afe5cf8b17e3a2269 to your computer and use it in GitHub Desktop.
Save davros85/33b0558c20bba93afe5cf8b17e3a2269 to your computer and use it in GitHub Desktop.
import * as ko from 'knockout';
export class EventBus {
private static _instance:EventBus = new EventBus();
// props for pub-sub
public myProp:KnockoutObservable<string> = ko.observable('');
constructor(){
if(EventBus._instance){
throw new Error('Cannot instantiate. Use EventBus.getInstance() instead');
}
EventBus._instance = this;
}
public static getInstance():EventBus{
return EventBus._instance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment