Skip to content

Commit 7210ffd

Browse files
author
Jelte Lagendijk
committed
Fix subscribe issue
1 parent 99f29a7 commit 7210ffd

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "FileDocumentViewer",
3-
"version": "2.2.0",
3+
"version": "2.2.1",
44
"description": "This widget lets you view file documents.",
55
"license": "",
66
"author": "",

src/FileDocumentViewer/widget/FileDocumentViewer.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,14 @@ require( [
6262

6363
update: function (obj, callback) {
6464
logger.debug(this.id + ".update");
65-
this._contextObj = obj;
66-
this._resetSubscriptions();
67-
this._updateRendering(callback);
65+
66+
if (obj) {
67+
this._contextObj = obj;
68+
this._resetSubscriptions();
69+
this._updateRendering(callback);
70+
} else {
71+
mendix.lang.nullExec(callback);
72+
}
6873
},
6974

7075
_updateRendering: function (callback) {
@@ -95,14 +100,16 @@ require( [
95100
_resetSubscriptions: function () {
96101
logger.debug(this.id + "._resetSubscriptions");
97102
if (this._handle) {
98-
this.unsubscribe(this._handle);
103+
mx.data.unsubscribe(this._handle);
99104
this._handle = null;
100105
}
101106

102107
if (this._contextObj) {
103-
this._handle = this.subscribe({
108+
this._handle = mx.data.subscribe({
104109
guid: this._contextObj.getGuid(),
105-
callback: this._updateRendering
110+
callback: lang.hitch(this, function () {
111+
this._updateRendering();
112+
})
106113
});
107114
}
108115
},
@@ -132,6 +139,14 @@ require( [
132139
_eventPopout : function () {
133140
logger.debug(this.id + "._eventPopout");
134141
window.open(this._getFileUrl());
142+
},
143+
144+
uninitialize: function () {
145+
if (this._handle) {
146+
mx.data.unsubscribe(this._handle);
147+
this._handle = null;
148+
}
149+
logger.debug(this.id + ".uninitialize");
135150
}
136151
});
137152
});

src/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="FileDocumentViewer" version="2.2.0" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="FileDocumentViewer" version="2.2.1" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="FileDocumentViewer/FileDocumentViewer.xml"/>
66
</widgetFiles>
-2 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)