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

Methods to avoid callback hell in PHP?

Discussion in 'Development' started by Legoboy0215, Jun 28, 2018.

  1. Legoboy0215

    Legoboy0215 Witch

    Messages:
    64
    GitHub:
    legoboy0215
    For those who work with asynchronous PHP with PocketMine, how do you avoid callback hell? I currently have code with tons of nested statements. Ex:
    PHP:
    public function doesExist(string $blah, callable $func) : void{
        
    $result lookThroughDatabase($blah);
        
    $func($result);
    }

    doesExist("hey", function(bool $bool){
        if(
    $bool){
            
    keepGoingWithAsyncCallbacks();
        }
    });
     
  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.