Skip to content

Commit

Permalink
Fix deprecated methods & subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelte Lagendijk committed Feb 2, 2017
1 parent f952120 commit 68e6399
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"name": "FileDocumentViewer",
"version": "2.2.3",
"version": "2.2.4",
"description": "This widget lets you view file documents.",
"license": "",
"author": "",
"private": true,
"dependencies": {
},
"dependencies": {},
"devDependencies": {
"del": "^2.2.2",
"gulp": "^3.9.1",
Expand Down Expand Up @@ -35,4 +34,4 @@
"folders": "node ./node_modules/gulp/bin/gulp folders",
"modeler": "node ./node_modules/gulp/bin/gulp modeler"
}
}
}
17 changes: 12 additions & 5 deletions src/FileDocumentViewer/widget/FileDocumentViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ require( [
this._resetSubscriptions();
this._updateRendering(callback);
} else {
mendix.lang.nullExec(callback);
this._executeCallback(callback, "update");
}
},

Expand All @@ -94,18 +94,18 @@ require( [
domAttr.set(this.headerTextNode, "innerHTML","...");
}

mendix.lang.nullExec(callback);
this._executeCallback(callback, "_updateRendering");
},

_resetSubscriptions: function () {
logger.debug(this.id + "._resetSubscriptions");
if (this._handle) {
mx.data.unsubscribe(this._handle);
this.unsubscribe(this._handle);
this._handle = null;
}

if (this._contextObj) {
this._handle = mx.data.subscribe({
this._handle = this.subscribe({
guid: this._contextObj.getGuid(),
callback: lang.hitch(this, function () {
this._updateRendering();
Expand Down Expand Up @@ -143,10 +143,17 @@ require( [

uninitialize: function () {
if (this._handle) {
mx.data.unsubscribe(this._handle);
this.unsubscribe(this._handle);
this._handle = null;
}
logger.debug(this.id + ".uninitialize");
},

_executeCallback: function (cb, from) {
logger.debug(this.id + "._executeCallback" + (from ? " from " + from : ""));
if (cb && typeof cb === "function") {
cb();
}
}
});
});
2 changes: 1 addition & 1 deletion src/package.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="FileDocumentViewer" version="2.2.3" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="FileDocumentViewer" version="2.2.4" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="FileDocumentViewer/FileDocumentViewer.xml"/>
</widgetFiles>
Expand Down
Binary file modified test/widgets/FileDocumentViewer.mpk
Binary file not shown.

0 comments on commit 68e6399

Please sign in to comment.