Skip to content

Instantly share code, notes, and snippets.

@vojtajina
Created May 10, 2014 16:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save vojtajina/0a3a59f28ea9b3b5cef0 to your computer and use it in GitHub Desktop.
An example of Node core module bindings for DI.
import {module as nodeBindings} from './node_bindings';
import {Injector} from 'di';
import {Foo} from './foo';
var injector = new Injector(nodeBindings);
var foo = injector.get(Foo);
import {Inject} from 'di';
module fs from 'fs';
@Inject(fs.readFile, fs.writeFile)
export class Foo {
constructor(readFile, writeFile) {}
}
var fs = require('fs');
export var module = [
bind(fs.readFile).toValue(fs.readFile),
bind(fs.writeFile).toValue(fs.writeFile),
// ...
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment