Skip to content

Instantly share code, notes, and snippets.

@ericelliott
Created October 2, 2016 01:02
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericelliott/5c17e25731f658c80fd88cdf78740f6c to your computer and use it in GitHub Desktop.
Save ericelliott/5c17e25731f658c80fd88cdf78740f6c to your computer and use it in GitHub Desktop.
Dependency Injection
const consumer = dependency => dependency.doSomething();
const realDependency = {
doSomething () {
console.log('did something!');
}
};
consumer(realDependency);
const mockDependency = {
doSomething () {
console.log('did something else!');
}
};
consumer(mockDependency);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment