|
|
@@ -42,6 +42,7 @@ function Seed (el, options) {
|
|
|
scope.$dump = this._dump.bind(this)
|
|
|
scope.$index = options.index
|
|
|
scope.$parent = options.parentSeed && options.parentSeed.scope
|
|
|
+ scope.$refresh = this._refreshBinding.bind(this)
|
|
|
|
|
|
// update bindings when a property is set
|
|
|
this.on('set', this._updateBinding.bind(this))
|
|
|
@@ -214,9 +215,11 @@ Seed.prototype._updateBinding = function (key, value) {
|
|
|
if (value.get) { // computed property
|
|
|
type = 'Computed'
|
|
|
value = value.get
|
|
|
+ } else { // normal object
|
|
|
+ // TODO watchObject
|
|
|
}
|
|
|
} else if (type === 'Array') {
|
|
|
- augmentArray(value)
|
|
|
+ watchArray(value)
|
|
|
value.on('mutate', function () {
|
|
|
if (binding.dependents) {
|
|
|
binding.refreshDependents()
|
|
|
@@ -240,6 +243,13 @@ Seed.prototype._updateBinding = function (key, value) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+Seed.prototype._refreshBinding = function (key) {
|
|
|
+ var binding = this._bindings[key]
|
|
|
+ binding.instances.forEach(function (instance) {
|
|
|
+ instance.refresh()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
Seed.prototype._unbind = function () {
|
|
|
var unbind = function (instance) {
|
|
|
if (instance.unbind) {
|
|
|
@@ -316,7 +326,7 @@ var arrayAugmentations = {
|
|
|
this.splice(index, 1, data)
|
|
|
}
|
|
|
}
|
|
|
-function augmentArray (collection) {
|
|
|
+function watchArray (collection) {
|
|
|
Emitter(collection)
|
|
|
arrayMutators.forEach(function (method) {
|
|
|
collection[method] = function () {
|