Skip to content

Commit

Permalink
Fix subscribe issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelte Lagendijk committed Apr 13, 2016
1 parent 99f29a7 commit 7210ffd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "FileDocumentViewer",
"version": "2.2.0",
"version": "2.2.1",
"description": "This widget lets you view file documents.",
"license": "",
"author": "",
Expand Down
27 changes: 21 additions & 6 deletions src/FileDocumentViewer/widget/FileDocumentViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ require( [

update: function (obj, callback) {
logger.debug(this.id + ".update");
this._contextObj = obj;
this._resetSubscriptions();
this._updateRendering(callback);

if (obj) {
this._contextObj = obj;
this._resetSubscriptions();
this._updateRendering(callback);
} else {
mendix.lang.nullExec(callback);
}
},

_updateRendering: function (callback) {
Expand Down Expand Up @@ -95,14 +100,16 @@ require( [
_resetSubscriptions: function () {
logger.debug(this.id + "._resetSubscriptions");
if (this._handle) {
this.unsubscribe(this._handle);
mx.data.unsubscribe(this._handle);
this._handle = null;
}

if (this._contextObj) {
this._handle = this.subscribe({
this._handle = mx.data.subscribe({
guid: this._contextObj.getGuid(),
callback: this._updateRendering
callback: lang.hitch(this, function () {
this._updateRendering();
})
});
}
},
Expand Down Expand Up @@ -132,6 +139,14 @@ require( [
_eventPopout : function () {
logger.debug(this.id + "._eventPopout");
window.open(this._getFileUrl());
},

uninitialize: function () {
if (this._handle) {
mx.data.unsubscribe(this._handle);
this._handle = null;
}
logger.debug(this.id + ".uninitialize");
}
});
});
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.0" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="FileDocumentViewer" version="2.2.1" 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 7210ffd

Please sign in to comment.