Skip to content
neonstalwart edited this page Aug 18, 2011 · 10 revisions

#twine

##overview twine is an asynchronous dependency inversion container. twine injects dependencies into components via object composition - ie mixins applied before construction.

dependency inversion coupled with twine's fibers extension API makes twine a very powerful tool. twine's power is exposed through a very simple configuration API that also makes twine easy to use.

define(function (require) {
  // create a container
  var Twine = require('twine');
  var container = new Twine();

  // configure the container
  container.configure({
    components: [
      {
        id: 'app',
        module: 'my/app',
        deps: {
          session: 'session'
        }
      },
      {
        id: 'session',
        module: 'my/app/session'
      }
    ]
  }).then(function (container) {
    // resolve your app
    container.resolve('app').then(function (app) {
      // start your app
      app.startup();

      // NOTE: app.session will be the session component

      // ... at some time later don't forget to cleanup
      container.destroy();
    });
  });
});

##influences the design of twine was influenced by Castle Windsor, Cairngorm 3 and Parsley. those frameworks should be commended for their clear and comprehensive documentation.

##documentation twine has a wiki.

##bugs you can report bugs via twine's issue tracker on github.

##source twine is available on github.

##license twine is available under the new BSD license. Copyright (c) 2011, Cello Software, LLC.

Clone this wiki locally