But thats what async doing .
Basics of Async ist to walk through function calls , and every call is a
exit , cause nothing wait for the answer (cause async)

so how ever you do it , the function your are in runs to the end what every
async you call , its done lately .

so you have to take another function and recall the function with that
params .


function parent{
 function childasync(
    callback() {
      afterasync(values); // cause you never know when it happend , now you
know it :)
    } )
 {
  // nothing should depend on global values cause you never know when they
set by async
 }
 function afterasync(values){
     // work with values;
 }

}



On 11 May 2015 at 08:21, Sándor Volenszki <[email protected]> wrote:

> Hi Pablo!
>
> Yes, this is exactly what I do now, and this is what I want to change,
> because this circumstance makes the code hardy maintenance.
>
> First I thought, I will have one retrun point, at the end of the script,
> but now I see, It wont work.
>
> Is it possible to make functions somehow in the registered command and
> calling this function instead of every return?
>
> Do you have any experience about this?
>
> 2015. május 9., szombat 18:25:29 UTC+2 időpontban Pablo a következőt írta:
>>
>> Hey,
>>
>> Sorry for the formatting, change your sample in my mobile. Try something
>> like this:
>>
>> Ape.registerCmd('somecommand', false, function(params, infos) {
>>    var channel = Ape.getChannelByPubid(params.pipe);
>>    ...
>>    sql.query("SELECT * FROM table", function(res, errorNo) {
>>
>> //And than I wnat to work with the res outside the sql, so here:
>>
>>
>>    if(res[0].someparam == 1){
>>        //Some bussines logic with sql queries and other stuff
>>    }
>>    else{
>>        //Some other bussines logic with sql queries and other stuff
>>    }
>>    ...
>>    if(channel){
>>        //And use here in the returning data
>>        channel.pipe.sendRaw('response',{'sqldata':res[0].somedata});
>>    }
>>
>>    });
>>
>>    return 1;
>> });
>>
>> On Sat, May 9, 2015, 11:04 AM Sándor Volenszki <[email protected]>
>> wrote:
>>
>>> Dear Pablo!
>>>
>>>
>>>  I don't want to be irksome, but I still don't understand, and I feel,
>>> I composed my question badly. So I did a snipet to represent my real
>>> problem:
>>>
>>>
>>>  Ape.registerCmd('somecommand', false, function(params, infos) {
>>>
>>>     var channel = Ape.getChannelByPubid(params.pipe);
>>>
>>>     ...
>>>
>>>     sql.query("SELECT * FROM table", function(res, errorNo) {
>>>
>>>         //Here I get the res, which contains all the mysql returned data
>>>
>>>     });
>>>
>>>     ...
>>>
>>>     //And than I wnat to work with the res outside the sql, so here:
>>>
>>>     if(res[0].someparam == 1){
>>>
>>>         //Some bussines logic with sql queries and other stuff
>>>
>>>     }
>>>
>>>     else{
>>>
>>>         //Some other bussines logic with sql queries and other stuff
>>>
>>>     }
>>>
>>>     ...
>>>
>>>     if(channel){
>>>
>>>         //And use here in the returning data
>>>
>>>         channel.pipe.sendRaw('response',{'sqldata':res[0].somedata});
>>>
>>>     }
>>>
>>>     else{
>>>
>>>         return ['109', 'UNKNOWN_PIPE'];
>>>
>>>     }
>>>
>>>
>>>      return 1;
>>>
>>> });
>>>
>>>
>>>  How can I do this?
>>>
>>>
>>>  Thank you for your attention!
>>>
>>>
>>> 2015. május 8., péntek 15:04:28 UTC+2 időpontban Pablo a következőt írta:
>>>
>>>> Hey guys,
>>>>
>>>> This a typical scenario in JS, you must call your function in the
>>>> callback. In the case of APE if you need to get the data back to the user
>>>> then in your function/callback you must sent a raw to the user pipe, like
>>>> Mike suggested. The response to the user does not needs to originate from
>>>> the original request.
>>>>
>>>> On Fri, May 8, 2015, 3:30 AM Sándor Volenszki <[email protected]>
>>>> wrote:
>>>>
>>> Hi Utan!
>>>>>
>>>>> Do you have any solution for this problem? I am also stucked here.
>>>>>
>>>>> Thanks in advice!
>>>>>
>>>>> 2012. január 24., kedd 21:49:29 UTC+1 időpontban UTAN a következőt
>>>>> írta:
>>>>>
>>>>>>
>>>>>> Did you solved this issue?
>>>>>>
>>>>>> Returning the callback var inside anonymous function and making
>>>>>> available to the parent function?
>>>>>> I am stuck on that..
>>>>>>
>>>>>> regards
>>>>>>
>>>>>> On Jan 16, 12:11 pm, Micael Ribeiros <[email protected]> wrote:
>>>>>> > Yes, but how do I process the data if I can only return it inside
>>>>>> the
>>>>>> > loop/callback, I cant even pass data to the callback, or can I?
>>>>>
>>>>>  --
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "APE Project" group.
>>>>>
>>>> To post to this group, send email to [email protected]
>>>>
>>>>
>>>>> To unsubscribe from this group, send email to
>>>>>
>>>> [email protected]
>>>>
>>>>
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/ape-project?hl=en
>>>>> ---
>>>>> APE Project (Ajax Push Engine)
>>>>> Official website : http://www.ape-project.org/
>>>>> Git Hub : http://github.com/APE-Project/
>>>>>
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "APE Project" group.
>>>>>
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>
>>>>
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>  --
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "APE Project" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/ape-project?hl=en
>>> ---
>>> APE Project (Ajax Push Engine)
>>> Official website : http://www.ape-project.org/
>>> Git Hub : http://github.com/APE-Project/
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "APE Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>  --
> --
> You received this message because you are subscribed to the Google
> Groups "APE Project" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/ape-project?hl=en
> ---
> APE Project (Ajax Push Engine)
> Official website : http://www.ape-project.org/
> Git Hub : http://github.com/APE-Project/
>
> ---
> You received this message because you are subscribed to the Google Groups
> "APE Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 
i cant trust, what i not know

-- 
-- 
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/

--- 
You received this message because you are subscribed to the Google Groups "APE 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to