Skip to content

Commit

Permalink
Make notifyCurrentValue() take variable number of arguments.
Browse files Browse the repository at this point in the history
Fixes #14.
  • Loading branch information
wkeese committed Dec 31, 2014
1 parent 44226c2 commit 51afb50
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
10 changes: 6 additions & 4 deletions Stateful.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,15 @@ define([
},

/**
* Notify current value to observers.
* Notify current values to observers for specified property name(s).
* Handy to manually schedule invocation of observer callbacks when there is no change in value.
* @method module:decor/Stateful#notifyCurrentValue
* @param {string} name The property name.
* @param {...string} name The property name.
*/
notifyCurrentValue: function (name) {
notify(this, name, this[propNames(name).p]);
notifyCurrentValue: function () {
Array.prototype.forEach.call(arguments, function (name) {
notify(this, name, this[propNames(name).p]);
}, this);
},

/**
Expand Down
13 changes: 9 additions & 4 deletions tests/unit/Stateful.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,19 @@ define([
"notifyCurrentValue()": function () {
var dfd = this.async(1000),
stateful = new (dcl(Stateful, {
foo: undefined
foo: undefined,
bar: undefined,
zaz: undefined
}))({
foo: "Foo"
foo: "Foo",
bar: "Bar",
zaz: "Zaz"
});
stateful.observe(dfd.callback(function (oldValues) {
assert.deepEqual(oldValues, {foo: "Foo"});
assert.deepEqual(oldValues, {foo: "Foo", bar: "Bar", zaz: "Zaz"});
}));
stateful.notifyCurrentValue("foo");
stateful.notifyCurrentValue("foo", "bar");
stateful.notifyCurrentValue("zaz");
},
"Stateful.PropertyListObserver#deliver(), Stateful.PropertyListObserver#discardChanges()": function () {
var changes = [],
Expand Down

0 comments on commit 51afb50

Please sign in to comment.