Hi!
This is my first post here, so a super brief intro… I’m a web developer in the UK, and am trying to build my first app using Corona - I like the language (LUA), I like that it can be compiled for ios and droid… and look and feel like a native app - correct me if i’m wrong? 
Anyway, today is my first solid day working with Corona SDK, and I keep getting stumped by two issues
- onPress for a button widget… can I not pass parameters?
e.g.
local somebutton = widget.newButton {
label=“test”,
top = 220,
left = 50,
onPress = testfunc(“some test string”)
};
function testfunc(var)
print(var)
end
- Handling network.request Callbacks elegantly
I have a function, lets call it “handler”. I pass it some parameters - lets call them p1,p2, p3, and p4 which tell it which methods from a REST API I have built and specific details like an id. p3 is an object (‘table’) in corona with some values - other parameters for the API request.
Once it has built up a URL for the service based on the parameters, my ‘handler’ function calls network.request (myurl,“GET”,callbackhander)
where callbackhandler is another function and myurl is the url for my REST action.
Problem: I have lots of callback functions for doing different things. The callback function I need to run depends on p1 and p2.
I was expecting to get the response inside “handler” and pass it to the right callback function based on logic around p1 and p2.
It seems I can only send the resultant response of my request to a single callback function?
and i loose scope for the original params in “handler” - how i handle the response and process it and what I do with it depends on those params!
Short of creating 2 functions for each REST function - a caller (network.request…) and a specific callback, I cant see what I can do here that would be neat!
Can anyone help??
There are about 20 functions that the REST API provides that I need to make calls to in my app.
Thanks for your help / any help given!! Really appreciated.
