Skip to content

Commit

Permalink
Changes resolvers to be a static dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarenaldi committed Jul 1, 2014
1 parent 348a93f commit 3a067e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import generateType from './generateType'
import invariant from './invariant'
import {ACQUIRE, RELEASE, DISPOSE} from './signals'
import { PROVIDER } from './options'
import createResolvers from './resolvers'
import resolvers from './resolvers'
import VALUE from './options'
import log from './log'

Expand All @@ -18,7 +18,7 @@ var CONTAINER_ALIAS = '$container'
class Container {

constructor(conf, mappings) {
this._resolvers = createResolvers()
this._resolvers = resolvers
this._mappings = mappings || {}
this._resolving = {}
this._pending = []
Expand Down
17 changes: 7 additions & 10 deletions src/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@ import {
CONSTRUCTOR,
SINGLETON
} from './options'

export default function createResolvers() {

var resolvers = {}
var resolvers = {}

resolvers[ generateType([VALUE]) ] = compose(leftCurryTwice, resolveDeps)(identity)
resolvers[ generateType([CONSTRUCTOR]) ] = compose(leftCurryTwice, resolveDeps)(instanciate)
resolvers[ generateType([CONSTRUCTOR, SINGLETON]) ] = singletonify(instanciate)
resolvers[ generateType([PROVIDER]) ] = compose(leftCurryTwice, resolveDeps)(invoke)
resolvers[ generateType([SINGLETON, PROVIDER]) ] = singletonify(invoke)
resolvers[ generateType([VALUE]) ] = compose(leftCurryTwice, resolveDeps)(identity)
resolvers[ generateType([CONSTRUCTOR]) ] = compose(leftCurryTwice, resolveDeps)(instanciate)
resolvers[ generateType([CONSTRUCTOR, SINGLETON]) ] = singletonify(instanciate)
resolvers[ generateType([PROVIDER]) ] = compose(leftCurryTwice, resolveDeps)(invoke)
resolvers[ generateType([SINGLETON, PROVIDER]) ] = singletonify(invoke)

return resolvers
}
export default resolvers

0 comments on commit 3a067e0

Please sign in to comment.