1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Get data from AsyncTask

Discussion in 'Development' started by artulloss, Sep 7, 2018.

  1. artulloss

    artulloss Witch

    Messages:
    63
    GitHub:
    artulloss
    I have an array that gets data added to it from an API inside an async task. I'd like to get this data and use it in my listener file so I can store the data for future use, and call it without calling the API, kind of like creating your own database for something that is called often.

    Information about the variable that I want to get:

    Variable is simply:

    public $data;

    Inside the class, Check, extending the Async Task.

    I would need to call it from inside a function on the Class that extends Listener

    Any help is appreciated, thanks!
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    on async on complete
    use the provided server call get pluginmanager then call get plugin
    provide it your name
    now you can pass the data from the async task
     
    artulloss likes this.
  3. artulloss

    artulloss Witch

    Messages:
    63
    GitHub:
    artulloss
    Can you give me an example of that, I had the part you just mentioned but I wasn't able to get the data to it

    It probably matters how I call the task, which is
    $this->getServer()->getAsyncPool()->submitTask(new SOMETHING($array, $string));
     
  4. artulloss

    artulloss Witch

    Messages:
    63
    GitHub:
    artulloss
    Figured it out thanks to looking through some example code, I was fixated on getting the data by returning but what I should have done is passed the data to a function. Plugin I made works perfectly now! Anyways thanks for helping it was what I needed to do I just didn't understand what u meant
     
    SOFe likes this.
  5. artulloss

    artulloss Witch

    Messages:
    63
    GitHub:
    artulloss
    Last edited: Sep 21, 2018
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.