Here you go,
dojo.provide("example.widget.SomeWidget");
mxui.widget.declare("example.widget.SomeWidget", {
//
// Skipping inheritance, inputargs, mixins, etc
//
shiftLabels : [],
shiftTimes : [],
postCreate : function() {
//
// Sequencer will set the scope to 'this'
// http://apidocs.mendix.com/client/lang.html#sequence
//
mendix.lang.sequence(this, [
this.getSomeObjects,
this.getSomeMoreObjects,
this.doJQueryStuff,
this.actRendered
]);
},
getSomeObjects : function(callback) {
//
// Both mx.processor.get and dojo.forEach take a scope argument
// ('this'), which takes care of setting the proper scope. If you
// don't pass the scope object you have to set the scope yourself
// using dojo.hitch!
//
mx.processor.get({
xpath : "//Module.Object",
callback : function(objs) {
dojo.forEach(objs, function(obj) {
this.shiftLabels.push(obj.get("ShiftLabel"));
}, this);
callback();
}
}, this);
},
getSomeMoreObjects : function(callback) {
mx.processor.get({
xpath : "//Module.Object",
callback : function(objs) {
dojo.forEach(objs, function(obj) {
this.shiftTimes.push(obj.get("ShiftTimes"));
}, this);
callback();
}
}, this);
},
doJQueryStuff : function(callback) {
//
// Do jQuery stuff, probably with this.shiftLabels and this.shiftTimes
//
callback();
}
});
Those arrays are already in the closure of your callback, so you can already use them.
Otherwise, you can bind them to your callback function using dojo.hitch:
...get({
...
callback : dojo.hitch(this, function(shiftLabels, shiftTimes, companyList) {
..your function..
}, shiftLabels, shiftTimes);
}
For more information, just google a bit around to find out how javascript closures, dynamic scoping works.