From 42f5b0a7fa758c6809c5a9051a9d01303900e1d2 Mon Sep 17 00:00:00 2001 From: Brian Cavalier Date: Sat, 28 Feb 2015 21:37:34 -0500 Subject: [PATCH] Update docs, bump version, update changelog --- CHANGES.md | 6 +++++- bower.json | 2 +- docs/components.md | 29 +++++++++++++++++++++++++++++ package.json | 4 ++-- wire.js | 6 +++--- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e39a53d..0c18e3c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +### 0.10.10 + +* Allow `create` to use a `$ref` to a factory function, as well as args to create components. + ### 0.10.9 * Allow arbitrarily deep dot traversal in `$ref`s. @@ -199,4 +203,4 @@ myTemplate: { * 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` \ No newline at end of file + * `dom.query!` reference resolver that uses `dojo.query` diff --git a/bower.json b/bower.json index 5bb2a46..169a9dd 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "wire", - "version": "0.10.9", + "version": "0.10.10", "main": "./wire.js", "dependencies": { "meld": "~1", diff --git a/docs/components.md b/docs/components.md index 243d19a..ed0613c 100644 --- a/docs/components.md +++ b/docs/components.md @@ -170,6 +170,24 @@ myComponent: { } ``` +The create factory can also accept a reference to a function, constructor, or object to use to create the new component. + +```js +factory: { + module: 'my/app/ModuleA' +}, +myComponent: { + create: { + // Call factory as a constructor or function + // factory can be any component that is a function, + // constructor, or object. + module: { $ref: 'factory' } + args: [arg1, arg2, arg3...] + } +} +``` + + ### Short Syntax ```javascript // This shorter syntax loads my/app/ModuleA and calls it with no args @@ -178,6 +196,17 @@ myComponent: { } ``` +```javascript +// The shorter syntax can use a reference as well +factory: { + module: 'my/app/ModuleA' +}, +myComponent: { + create: { $ref: 'factory' } +} +``` + + ### isConstructor option notes The create factory uses a set of simple heuristics to determine automatically whether to call the module as a constructor using `new`, or as a regular function. diff --git a/package.json b/package.json index d096fd5..0bc4877 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wire", - "version": "0.10.9", + "version": "0.10.10", "description": "A light, fast, flexible Javascript IOC container.", "keywords": [ "ioc", @@ -54,4 +54,4 @@ "test": "buster-test -e node", "prepublish": "bower install" } -} \ No newline at end of file +} diff --git a/wire.js b/wire.js index 070c21d..1fdf1d7 100644 --- a/wire.js +++ b/wire.js @@ -11,14 +11,14 @@ * * @author Brian Cavalier * @author John Hann - * @version 0.10.9 + * @version 0.10.10 */ (function(rootSpec, define){ 'use strict'; define(function(require) { var createContext, rootContext, rootOptions; - wire.version = '0.10.9'; + wire.version = '0.10.10'; createContext = require('./lib/context'); @@ -96,4 +96,4 @@ define(function(require) { this['wire'] || {}, typeof define == 'function' && define.amd ? define : function(factory) { module.exports = factory(require); } -); \ No newline at end of file +);