ecowden / pluto.js

JavaScript Dependency Injection
MIT License
8 stars 3 forks source link

Improve Syntax #27

Closed ecowden closed 7 years ago

ecowden commented 7 years ago

The weird callback thing is just ugly. Instead, consider something cleaner:

const pluto = require('pluto')
const bind = pluto()

const myInstance = {}
pluto.bind('myInstance').toInstance(myInstance) // and other bindings

const promise = pluto.get('myInstance') // get(...) must return a promise to support async

promise.then( (result) => {
  t.is(result, myInstance)
})
ecowden commented 7 years ago

Fixed on one-oh-redesign branch.