Results 1 to 6 of 6
  1. siogeek's Avatar
    Posts
    24 Posts
    Global Posts
    26 Global Posts
       #1  
    I would like to make a synchronous database call, but all the examples I've seen require you to write a closure and are asynchronous.

    Basically I want to use query results in code.

    Is this possible? Does anyone have any workarounds or suggestions?
  2. #2  
    I believe you can do this just by making your async db call. then sit in a loop calling a dummy function till your onGetSuccess method of the db call is complete and sets the loop flag to complete. The important thing is that your loop calls a dummy function that does something meaningless like increment a variable or something so that the async db success method can run.
  3. siogeek's Avatar
    Posts
    24 Posts
    Global Posts
    26 Global Posts
       #3  
    That's how I solved the problem, but it seemed like there would be a more elegant solution.
  4. #4  
    An asynchronous call is an elegant solution. Why not just have your "next steps" code called by the success handler?
  5. siogeek's Avatar
    Posts
    24 Posts
    Global Posts
    26 Global Posts
       #5  
    Quote Originally Posted by Blubble View Post
    An asynchronous call is an elegant solution. Why not just have your "next steps" code called by the success handler?
    I like that idea a little bit better then writing our own blocking loop, but it still seems like there would be a need, at times, to be able to make a quick asynchronous call to the database an immediately use the output.

    Thanks for the input.
  6. #6  
    The problem is that the queries can take up to a few seconds in some cases. An asynchronous solution allows your app to continue to other things in the meantime.

    If you are dealing with very small amounts of simple data, you can try using the cookies feature. According to the docs, the cookie calls are synchronous. I have only used the depot and the full database storage, so I can't opine on how the cookies work.

    Storage €“ webOSdev €“ Palm

Tags for this Thread

Posting Permissions