Created
May 10, 2014 16:32
-
-
Save vojtajina/0a3a59f28ea9b3b5cef0 to your computer and use it in GitHub Desktop.
An example of Node core module bindings for DI.
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
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); |
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
import {Inject} from 'di'; | |
module fs from 'fs'; | |
@Inject(fs.readFile, fs.writeFile) | |
export class Foo { | |
constructor(readFile, writeFile) {} | |
} |
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
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