1.6.0 • Published 6 years ago

injectinto v1.6.0

Weekly downloads
43
License
-
Repository
github
Last release
6 years ago

Dependency Injection

config.coffee

inject = require 'pminject'

inject.bind templaterenderer: require 'nun'
inject.bind contenttypes: [
    require './contenttypes/text'
    require './contenttypes/image'
]

cms.coffee

inject = require 'pminject'

contenttypes = inject.many 'contenttypes'
templaterenderer = inject.one 'templaterenderer'

for contenttype in contenttypes
    templaterenderer.render contenttype

What is the problem?

I'd like to build systems that can easily be extended, enhanced, or replaced.

How injectinto solves this problem

  1. Extension points are defined through strings, for example 'templateengine'
  2. In configuration these extension points are bound to actual objects
  3. A module asks for an object via it's string, for example 'templateengine'
  4. Some modules can expect an array of objects

Goals

  1. Simple
  2. Work with async
  3. Allow multiple registrations
1.6.0

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago