Created
July 4, 2023 15:06
-
-
Save edubskiy/86c679254f98f350c06d390b24fe4cdf to your computer and use it in GitHub Desktop.
Typescript Adapter pattern Implementation and Demo
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
namespace AdapterPattern { | |
export class Adaptee { | |
public method(): void { | |
console.log("`method` of Adaptee is being called"); | |
} | |
} | |
export interface Target { | |
call(): void; | |
} | |
export class Adapter implements Target { | |
public call(): void { | |
console.log("Adapter's `call` method is being called"); | |
var adaptee: Adaptee = new Adaptee(); | |
adaptee.method(); | |
} | |
} | |
} | |
// --------------- DEMO ----------------- // | |
namespace AdapterPattern { | |
export namespace Demo { | |
export function show() : void { | |
var adapter: AdapterPattern.Adapter = new AdapterPattern.Adapter(); | |
adapter.call(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment