c()
/**
* @throws Throwable
*
* This method is used to create a new promise.
*/
public static function c(callable $callback, bool $justGetResult = false): Promise;Usually you just need to use like this:
$promise = new Promise(function($resolve, $reject) {
$resolve("Hello World");
});With the c() method, you can implement it briefly with the Arrow Promise type:
Promise::c(fn($resolve, $reject) => $resolve("Hello World"));Even if you don't like the new Class() format, you can use it to make a promise at the top:
Promise::c(function($resolve, $reject) {
$resolve("Hello World");
});Last updated