Last active
July 6, 2018 20:47
-
-
Save mattwelke/6672df90edd052c285d4727c08aec3d8 to your computer and use it in GitHub Desktop.
sdgsdgaegeag
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
class Parent { | |
private readonly _child: Child; | |
constructor() { | |
// Make a DataDog counter and wrap the child's functions | |
this._child = new Child(); | |
const dataDogCounter = new DataDogCounter(); | |
} | |
public doLotsOfStuff() { | |
// Calls multiple functions of Child. | |
// Send doSomeStuff's messages here. This is the parent class. It knows what details to include. | |
dataDogCounter.sendMessage({/* tags for this situation, etc */}); | |
this._child.doSomeStuff(); | |
// Send doSomeOtherStuff's messages here. This is the parent class. It knows what details to include. | |
dataDogCounter.sendMessage({/* tags for this situation, etc */}); | |
this._child.doSomeOtherStuff(); | |
// Note, no need to inject logic for message sending anymore. Parent class (or function, whatever) does the message | |
// sending. If multiple counts need to be maintained (like for counting invokations of more than function), multiple | |
// instances of DataDogCounter could be created as members of Parent class. | |
} | |
} | |
class Child { | |
public doSomeStuff() { } | |
public doSomeOtherStuff() { } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment