ampersand-state
Advanced tools
Comparing version 4.3.12 to 4.3.13
{ | ||
"name": "ampersand-state", | ||
"description": "An observable, extensible state object with derived watchable properties.", | ||
"version": "4.3.12", | ||
"version": "4.3.13", | ||
"author": "Henrik Joreteg <henrik@andyet.net>", | ||
@@ -6,0 +6,0 @@ "bugs": { |
@@ -323,3 +323,3 @@ # ampersand-state | ||
props: { | ||
name: 'Phil' | ||
name: 'string' | ||
}, | ||
@@ -346,2 +346,45 @@ children: { | ||
### collections `AmpersandState.extend({ collections: { widgets: Widgets } })` | ||
Define child collection objects to attach to the object. Attributes passed to the constructor or to `set()` will be proxied to the collections. | ||
```javascript | ||
var State = require('ampersand-state'); | ||
var Collection = require('ampersand-collection'); | ||
var Widget = State.extend({ | ||
props: { | ||
name: 'string', | ||
funLevel: 'number' | ||
} | ||
}); | ||
var WidgetCollection = Collection.extend({ | ||
model: Widget | ||
}); | ||
var Person = AmpersandState.extend({ | ||
props: { | ||
name: 'string' | ||
}, | ||
collections: { | ||
widgets: WidgetCollection | ||
} | ||
}); | ||
var me = new Person({ | ||
name: 'Henrik', | ||
widgets: [ | ||
{ name: 'rc car', funLevel: 8 }, | ||
{ name: 'skis', funLevel: 11 } | ||
] | ||
}); | ||
console.log(me.widgets.length); //=> 2 | ||
console.log(me.widgets instanceof WidgetCollection); //=> true | ||
``` | ||
Note that currently, events *don't* bubble from collections to parent automatically. This is done for efficiency reasons. But there are discussions ongoing about how to best handle this case. | ||
### parse | ||
@@ -348,0 +391,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
111352
526