Skip to content
briancavalier edited this page Jun 4, 2011 · 4 revisions

When you feed a spec to wire.js as input, it produces a context. The context is a Javascript Object that contains the all fully realized objects, modules, values, etc. that were specified in the wiring spec. The context also has methods for wiring child contexts, resolving references, and destroying the context and all the objects, etc. that were created when it was wired.

Context example

Let's look again at the simple wiring spec from the Hello Wire example.

define({
	message: "I haz been wired",
	helloWired: {
		create: {
			module: 'hello-wired',
			args: { $ref: 'dom!hello' }
		},
		init: {
			sayHello: { $ref: 'message' }
		}
	},
	plugins: [
		{ module: 'wire/dom' }
	]
});
require(['wire!hello-wired-spec'], function(wired) {
    alert(wired.message);
});

Context hierarchy

The Root context

Clone this wiki locally