Closed Raruto closed 10 months ago
The following function appears to be unused:
because it is probably called with the wrong context in here (ref:
return function(
):
@Raruto it used https://github.com/g3w-suite/g3w-client-plugin-editing/blob/edd33b1dd02cdeaff676799942928f3ad899e96e/workflows/steps/tasks/openformtask.js#L297-L300 as you report.
it used
@volterra79 vscode editor shows me as unusued..
The "this" context is wrong.
That means, this._saveFnc(promise, context, inputs).bind(this)
doesn't work as you would excpect, because:
proto._saveFnc = function(promise, context, inputs) {
return function(fields) { // <-- this is NOT an arrow function (ie. () => { this._saveFeatures({ .. }); }),
this._saveFeatures({ .. }); // so the "this._saveFeatures" no longer refers to class method
}
}
it used
@volterra79 vscode editor shows me as unusued..
The "this" context is wrong.
That means,
this._saveFnc(promise, context, inputs).bind(this)
doesn't work as you would excpect, because:proto._saveFnc = function(promise, context, inputs) { return function(fields) { // <-- this is NOT an arrow function (ie. () => { this._saveFeatures({ .. }); }), this._saveFeatures({ .. }); // so the "this._saveFeatures" no longer refers to class method } }
@Raruto
cbk: this._saveFnc(promise, context, inputs).bind(this)
returns a function that is bind to OpenFormTask
It used by form save button to has a refence to openformtask instance.
Did you try to log this?
proto._saveFnc = function(promise, context, inputs) {
return function(fields) {
//console.log(this)
const session = context.session;
this._saveFeatures({
fields,
promise,
session,
inputs
});
}
};
Damn parentheses..
this._saveFnc(promise, context, inputs).bind(this)
In your opinion, is there a simple way to rewrite it like the following?
this._saveFnc(this, promise, context, inputs)
Damn parentheses..
this._saveFnc(promise, context, inputs).bind(this)
In your opinion, is there a simple way to rewrite it like the following?
this._saveFnc(this, promise, context, inputs)
@Raruto or just change
this._saveFnc(promise, context, inputs)
proto._saveFnc = function(promise, context, inputs) {
return (fields) => {
const session = context.session;
this._saveFeatures({
fields,
promise,
session,
inputs
});
}
@Raruto we can close it?
The following function appears to be unused:
https://github.com/g3w-suite/g3w-client-plugin-editing/blob/edd33b1dd02cdeaff676799942928f3ad899e96e/workflows/steps/tasks/openformtask.js#L234
because it is probably called with the wrong context in here (ref:
return function(
):https://github.com/g3w-suite/g3w-client-plugin-editing/blob/edd33b1dd02cdeaff676799942928f3ad899e96e/workflows/steps/tasks/openformtask.js#L297-L300
https://github.com/g3w-suite/g3w-client-plugin-editing/blob/edd33b1dd02cdeaff676799942928f3ad899e96e/workflows/steps/tasks/openformtask.js#L359