Skip to content

Commit

Permalink
Can be notified of bound propery changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bmavity committed May 4, 2013
1 parent 2103524 commit 062cea0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions wagner.ko.js
@@ -1,6 +1,12 @@
var ko = require('knockout')
, mapping = require('./ko-mapping')

function oi(obj, cb) {
Object.keys(obj).forEach(function(key) {
cb(obj[key], key)
})
}

function knockoutDataBinder(options) {
var handlers = {}
, root = this._root
Expand All @@ -14,6 +20,11 @@ function knockoutDataBinder(options) {
viewModel = mapping.fromJS(obj)
}
ko.applyBindings(viewModel, root)
if(options.notifyOn) {
oi(options.notifyOn, function(fn, key) {
viewModel[key].subscribe(fn)
})
}
}

function ensureViewModel(schema) {
Expand Down

0 comments on commit 062cea0

Please sign in to comment.