Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A light, fast, flexible Javascript IOC container

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
wire
LICENSE.txt
README.md
wire.js

README.md

wire.js

Wire.js is an Inversion of Control Container for Javascript apps.

With wire.js, you can focus on coding the business logic of your components and let wire.js handle the bootstrapping and the glue that connects them together. You write a simple wiring spec in JSON (or Javascript) that describes how your components should be wired together, and wire will load, configure, and connect those components to create your application, and will clean them up later.

Specifically, wire.js provides:

  • Component lifecycle management
  • Dependency Inversion via constructor and setter Dependency Injection
  • Automatic dependency ordering
  • Connectors
  • Service locator pattern and reference resolution

Plugins

Wire.js also has a plugin architecture that allows plugins to provide new capabilities to wire.js and syntax to wiring specs. Here are some of the capabilities provided by the bundled plugins:

  • Dependency Injection for DOM nodes. For example, you can reference DOM nodes by id or dom query, and inject them into your views.
  • Event and PubSub connectors. Write your components without any glue code, and connect them together in the wiring spec using events or pubsub. The event connector works for DOM nodes, too!
  • Aspect Oriented Programming (AOP). Wire.js comes with an AOP plugin that allows you to declaratively apply decorators, before/after/around advice, and to introduce mixins on the fly.

Plugins also allow you to use capabilities of your existing modules/libraries/frameworks. For example, wire.js has a set of plugins for Dojo that allow it to integrate with Dijit's widget system, to use dojo.connect as the event connector, and dojo.publish/subscribe as the pubsub connector. If you are already using those aspects of Dojo, you can use wire.js's Dojo plugins to integrate easily with all your existing components.

Ok, What Now?

  1. Read about and try out the Hello Wire introduction.
  2. Check out the wire.js presentation from JSConf 2011.
  3. Get the code for the Piratescript or N00bscript game from the presentation. Docs coming soon!
  4. See the wiki for more documentation.
  5. Fork it and try it out!

What's New

0.5

  • Re-engineered core: smaller, faster, and more loader-independent,
  • Can be used as either an AMD module or an AMD plugin,
  • Tested with curl.js, and RequireJS. Should also work with the upcoming dojo 1.7 loader (but hasn't been tested yet),
  • Improved plugin system,
  • AOP plugin, wire/aop: Decorators and Introductions. Coming Soon: before, after, afterReturning, afterThrowing, and around advice,
  • Prototype factory plugin allows using the JS prototype chain to create new objects directly from other objects in your wire spec.
  • Sizzle plugin, wire/sizzle, courtesy of @unscriptable
  • Not entirely new to 0.5, but worth mentioning Dojo integration, including:
    • pubsub connector, subscribe and publish non-invasively using dojo.publish/subscribe
    • event connector that uses dojo.connect
    • easy JsonRest datastores via resource! reference resolver
    • dom.query! reference resolver that uses dojo.query

Roadmap

  • More documentation
  • AOP before, after, afterReturning, afterThrowing, and around advice
  • AOP weaving. Apply cross-cutting AOP via pointcut queries
  • Defer module loading, and object creation or initialization (lazy load, create, init) until object is referenced or used.
  • Fully automated test suite. (Test suite is comprehensive, but manual right now)
  • Support for more AMD loaders
  • Integration with more libs and frameworks.
  • Node.js support
  • More modular, reusable wire specs by "#include"ing one spec in another

License

wire.js is licensed under The MIT License.

Something went wrong with that request. Please try again.