Skip to content

Instantly share code, notes, and snippets.

@vojtajina
Created May 10, 2014
Embed
What would you like to do?
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