Created
March 21, 2025 18:15
-
-
Save trikitrok/491b21f6e9968375bbea034738029864 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export class MessageRouter { | |
public route(message: Message): void { | |
//!! ouch... x( | |
ExternalRouter.getInstance().sendMessage(message); | |
} | |
} | |
export class ExternalRouter { // another Singleton! x( | |
private static instance: ExternalRouter | null = null; | |
private constructor() { | |
// initialize stuff | |
} | |
public static getInstance(): ExternalRouter { | |
if (this.instance === null) { | |
this.instance = new ExternalRouter(); | |
} | |
return this.instance; | |
} | |
// more code... | |
public sendMessage(message: Message): void { | |
// interesting code to send the message | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment