Closed DouglasHennrich closed 8 years ago
Yo! That's not possible, and is not a feature I will add. What about binding a context?
function handleSuccess(response){
if(this.something) //
};
new Alloy.Globals.HTTPRequest({
method: "POST",
url: config.url + 'consulta_todos.php',
data: _params
})
.then(handleSuccess.bind({ something: true }))
.catch(handleError);
never use promises before... if you say it work I will give a try =P
another question... to catch the onloadprogress
how should I do ? An .then(..)
before handleSuccess
?
Thanks
Binding a context is pure javascript, not specific to Promises ;)
About the progress handler, it's indeed a good question because there's no way to use promise handler yet (not in Promises A+ specs...). So you'll have to give the progress handler as a parameter:
function progressHandler(progress){
Ti.API.info(progress);
};
new Alloy.Globals.HTTPRequest({
method, url, data,
progress: progressHandler
})
.then(handleSuccess)
.catch(handleError);
Thaanks dude! :D
bind
work by the way
There's a way to pass more parameters? I want to pass some control variables to be handle on
success
of myhttprequest
, but now I'm only getting the response of thehttprequest
. Maybe something like:Thanks