Hi Paul,
I'd have to see the complete code to see what it does. From what I see in the snippet above, I have the following points:
1.)
var lat = this._getLat();
will not work. The mx.data.action
is asynchronous, so the function ._getLat()
will not return anything.
2.)
callback : dojoLang.hitch(this, this._processMF, callback),
will result in _processMF being called after the microflow has been executed. If you add the extra parameter (callback), this will be the first parameter that is used in the function that is being called (in this case: _processMF). That being said, it means you have to make sure that in this function, the callback is the first parameter. The microflow returns a string, so that becomes the second parameter in your callback function (of mx.data.action). Thus:
_processMF: function (callback, returnedString) {
(Check https://github.com/mendix/CustomString/blob/master/src/CustomString/widget/CustomString.js#L122)
3.)
So why do we pass this callback everywhere? That's because this callback function initially comes from update: function(obj, callback)
, where the callback is a function that is being passed by Mendix/Dojo (need to look this up). This callback function, when executed, essentially tells the page "hey! I have rendered my widget". So you want to make sure that this callback is being called AFTER you have complete rendered your widget (or updated your rendering).
Anyway, I'd have to see the complete code of the widget js to see what you try to accomplish. You could share it as a Gist if you want. You know where to find me on Github :-)
I'll post this in an answer, since the response is to long for a comment, but I was able to get it working by changing the callback functions of the microflows. These link to the same function and the processing continues from there.. Atleast my variables have data now.. Onto the next challenge :-)
Looking at the dojo.hitch documentation got me in the right direction!
Thanks Jelte and Chris for thinking with me!
Is there a way to do this in the new Pluggable Widget?
Currently I am using mendix v8.5.6
Change:
callback : dojoLang.hitch(this, this._processMF, callback),
to
callback : dojoLang.hitch(this, this._processMF),
and remove the callback parameter from processMF.
Hi Jelte,
Thanks for your answer and explanation. Let me try to explain it a bit more. What I want to do is have the microflows return a latitude and longitude value from a microflow ( so that the user is free to use what logic he wants to get this data) and use that value to get a weather forecast based on an API call.
I have put some extra variables in there that might be unneeded, but I'd like to think that I'd learn something from that...
The gist can be found here Gist link
I basically wanted to expaned the _createSkycon function to get the forecast using another function if the boolean (useForecast) was set to true