Skip to content

Instantly share code, notes, and snippets.

@mattwelke
Last active July 6, 2018 20:47
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 mattwelke/6672df90edd052c285d4727c08aec3d8 to your computer and use it in GitHub Desktop.
Save mattwelke/6672df90edd052c285d4727c08aec3d8 to your computer and use it in GitHub Desktop.
sdgsdgaegeag
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