Skip to content

Commit

Permalink
updated all tests and dists, as well as version number
Browse files Browse the repository at this point in the history
  • Loading branch information
grofit committed Jun 9, 2016
1 parent b967aa6 commit 0af0b80
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 50 deletions.
25 changes: 13 additions & 12 deletions dist/treacherous.all.js
Original file line number Diff line number Diff line change
Expand Up @@ -7133,17 +7133,17 @@ return /******/ (function(modules) { // webpackBootstrap
currentValue = _this.propertyResolver.resolveProperty(_this.model, paramRoute);
hasValue = true;
}
catch (ex) {}

if ((currentValue == null || typeof(currentValue) == "undefined") && (anyRulesAreForEach || anyRulesAreSets)) {
catch (ex) { }
if (currentValue == null && (anyRulesAreForEach || anyRulesAreSets)) {
if (anyRulesAreForEach) {
currentValue = [];
}
else if (anyRulesAreSets) {
currentValue = {};
}
else
{ currentValue = null; }
else {
currentValue = null;
}
}
parameterRules.forEach(function (rule) {
var isArray = type_helper_1.TypeHelper.isArrayType(currentValue);
Expand Down Expand Up @@ -7190,29 +7190,30 @@ return /******/ (function(modules) { // webpackBootstrap
return;
}
var refreshOnNextCycle = false;
console.log("watcher cache", _this.watchCache);
_this.watchCache.forEach(function (propertyWatcher) {
var currentValue;
var hasChanged = false;
try {
currentValue = _this.propertyResolver.resolveProperty(_this.model, propertyWatcher.propertyPath);
}
catch (ex) { }

if(typeof(currentValue) == "undefined" )
{ currentValue = propertyWatcher.previousValue; }

if (typeof (currentValue) == "undefined") {
currentValue = propertyWatcher.previousValue;
}
if (propertyWatcher.previousValue && propertyWatcher.previousValue.isArray) {
var currentLength = currentValue.length || 0;
console.log("has changed?", currentLength != propertyWatcher.previousValue.length);
if (currentLength != propertyWatcher.previousValue.length) {
refreshOnNextCycle = true;
hasChanged = true;
}
}
else if (currentValue !== propertyWatcher.previousValue) {
var propertyChangedArgs = new property_changed_event_1.PropertyChangedEvent(propertyWatcher.propertyPath, currentValue, propertyWatcher.previousValue);
setTimeout(function () { _this.onPropertyChanged.publish(propertyChangedArgs); }, 1);
propertyWatcher.previousValue = currentValue;
}
if (hasChanged) {
refreshOnNextCycle = true;
}
});
if (refreshOnNextCycle) {
setTimeout(_this.updateAndNotifyDifferences, 1);
Expand Down
19 changes: 11 additions & 8 deletions dist/treacherous.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1232,21 +1232,21 @@ return /******/ (function(modules) { // webpackBootstrap
}
});
hasValue = false;
currentValue = null;
try {
currentValue = _this.propertyResolver.resolveProperty(_this.model, paramRoute);
hasValue = true;
}
catch (ex) {
currentValue = null;
}
catch (ex) { }
if (currentValue == null && (anyRulesAreForEach || anyRulesAreSets)) {
if (anyRulesAreForEach) {
currentValue = [];
}
else if (anyRulesAreSets) {
currentValue = {};
}
else {
currentValue = null;
}
}
parameterRules.forEach(function (rule) {
var isArray = type_helper_1.TypeHelper.isArrayType(currentValue);
Expand Down Expand Up @@ -1293,27 +1293,30 @@ return /******/ (function(modules) { // webpackBootstrap
return;
}
var refreshOnNextCycle = false;
console.log("watcher cache", _this.watchCache);
_this.watchCache.forEach(function (propertyWatcher) {
var currentValue;
var hasChanged = false;
try {
currentValue = _this.propertyResolver.resolveProperty(_this.model, propertyWatcher.propertyPath);
}
catch (ex) {
catch (ex) { }
if (typeof (currentValue) == "undefined") {
currentValue = propertyWatcher.previousValue;
}
if (propertyWatcher.previousValue && propertyWatcher.previousValue.isArray) {
var currentLength = currentValue.length || 0;
console.log("has changed?", currentLength != propertyWatcher.previousValue.length);
if (currentLength != propertyWatcher.previousValue.length) {
refreshOnNextCycle = true;
hasChanged = true;
}
}
else if (currentValue !== propertyWatcher.previousValue) {
var propertyChangedArgs = new property_changed_event_1.PropertyChangedEvent(propertyWatcher.propertyPath, currentValue, propertyWatcher.previousValue);
setTimeout(function () { _this.onPropertyChanged.publish(propertyChangedArgs); }, 1);
propertyWatcher.previousValue = currentValue;
}
if (hasChanged) {
refreshOnNextCycle = true;
}
});
if (refreshOnNextCycle) {
setTimeout(_this.updateAndNotifyDifferences, 1);
Expand Down
19 changes: 11 additions & 8 deletions dist/treacherous.js
Original file line number Diff line number Diff line change
Expand Up @@ -1232,21 +1232,21 @@ return /******/ (function(modules) { // webpackBootstrap
}
});
hasValue = false;
currentValue = null;
try {
currentValue = _this.propertyResolver.resolveProperty(_this.model, paramRoute);
hasValue = true;
}
catch (ex) {
currentValue = null;
}
catch (ex) { }
if (currentValue == null && (anyRulesAreForEach || anyRulesAreSets)) {
if (anyRulesAreForEach) {
currentValue = [];
}
else if (anyRulesAreSets) {
currentValue = {};
}
else {
currentValue = null;
}
}
parameterRules.forEach(function (rule) {
var isArray = type_helper_1.TypeHelper.isArrayType(currentValue);
Expand Down Expand Up @@ -1293,27 +1293,30 @@ return /******/ (function(modules) { // webpackBootstrap
return;
}
var refreshOnNextCycle = false;
console.log("watcher cache", _this.watchCache);
_this.watchCache.forEach(function (propertyWatcher) {
var currentValue;
var hasChanged = false;
try {
currentValue = _this.propertyResolver.resolveProperty(_this.model, propertyWatcher.propertyPath);
}
catch (ex) {
catch (ex) { }
if (typeof (currentValue) == "undefined") {
currentValue = propertyWatcher.previousValue;
}
if (propertyWatcher.previousValue && propertyWatcher.previousValue.isArray) {
var currentLength = currentValue.length || 0;
console.log("has changed?", currentLength != propertyWatcher.previousValue.length);
if (currentLength != propertyWatcher.previousValue.length) {
refreshOnNextCycle = true;
hasChanged = true;
}
}
else if (currentValue !== propertyWatcher.previousValue) {
var propertyChangedArgs = new property_changed_event_1.PropertyChangedEvent(propertyWatcher.propertyPath, currentValue, propertyWatcher.previousValue);
setTimeout(function () { _this.onPropertyChanged.publish(propertyChangedArgs); }, 1);
propertyWatcher.previousValue = currentValue;
}
if (hasChanged) {
refreshOnNextCycle = true;
}
});
if (refreshOnNextCycle) {
setTimeout(_this.updateAndNotifyDifferences, 1);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "treacherous",
"version": "0.6.3",
"version": "0.7.0",
"license": "MIT",
"dependencies": {
"bluebird": "^3.3.4",
Expand Down
29 changes: 13 additions & 16 deletions src/watcher/model-watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,18 @@ export class ModelWatcher implements IModelWatcher
});

hasValue = false;
currentValue = null;

try
{
currentValue = this.propertyResolver.resolveProperty(this.model, paramRoute);
hasValue = true;
}
catch (ex) {
currentValue = null;
}
catch (ex) {}

if(currentValue == null && (anyRulesAreForEach || anyRulesAreSets))
{
if (anyRulesAreForEach) { currentValue = []; }
else if (anyRulesAreSets) { currentValue = {}; }
else { currentValue = null; }
}

parameterRules.forEach((rule) => {
Expand Down Expand Up @@ -170,31 +167,31 @@ export class ModelWatcher implements IModelWatcher
if(this.watchCache.length == 0) { return; }

var refreshOnNextCycle = false;
console.log("watcher cache", this.watchCache);
this.watchCache.forEach((propertyWatcher: PropertyWatcher) => {
var currentValue;
var hasChanged = false;

try
{
currentValue = this.propertyResolver.resolveProperty(this.model, propertyWatcher.propertyPath);
}
catch(ex)
{
currentValue = propertyWatcher.previousValue;
}
{ currentValue = this.propertyResolver.resolveProperty(this.model, propertyWatcher.propertyPath); }
catch(ex) { }

if(typeof(currentValue) == "undefined")
{ currentValue = propertyWatcher.previousValue; }

if(propertyWatcher.previousValue && propertyWatcher.previousValue.isArray)
{
var currentLength = currentValue.length || 0;

console.log("has changed?", currentLength != propertyWatcher.previousValue.length);
if(currentLength != propertyWatcher.previousValue.length)
{ refreshOnNextCycle = true; }
{ hasChanged = true; }
}
else if (currentValue !== propertyWatcher.previousValue) {
var propertyChangedArgs = new PropertyChangedEvent(propertyWatcher.propertyPath, currentValue, propertyWatcher.previousValue);
setTimeout(() => { this.onPropertyChanged.publish(propertyChangedArgs); }, 1);
propertyWatcher.previousValue = currentValue;
}

if(hasChanged)
{ refreshOnNextCycle = true; }
});

if(refreshOnNextCycle)
Expand Down
7 changes: 2 additions & 5 deletions tests/specs/model-watcher-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,12 @@ describe('Model Watcher', function () {
var spySubscription = chai.spy(function(eventArgs){ console.log("event", eventArgs); });
modelWatcher.onPropertyChanged.subscribe(spySubscription);

dummyModel = {
foo: 11,
bar: [11, 12]
};
dummyModel.foo = 11;
dummyModel.bar = [11, 12];

setTimeout(function(){
// once for foo, once for bar, once for bar[0] and then bar[1]
expect(spySubscription).to.have.been.called.exactly(4);
expect(true).to.equal(false);
modelWatcher.stopWatching();
done();
}, 250);
Expand Down

0 comments on commit 0af0b80

Please sign in to comment.