• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/web/http/promise.php
  • Класс: BitrixMainWebHttpPromise
  • Вызов: Promise::then
public function then(callable $onFulfilled = null, callable $onRejected = null)
{
	$state = $this->getState();

	if ($onFulfilled)
	{
		if ($state == self::PENDING)
		{
			$this->onFulfilled[] = $onFulfilled;
		}
		elseif ($state == self::FULFILLED)
		{
			call_user_func($onFulfilled, $this->response);
		}
	}

	if ($onRejected)
	{
		if ($state == self::PENDING)
		{
			$this->onRejected[] = $onRejected;
		}
		elseif ($state == self::REJECTED)
		{
			$this->exception = call_user_func($onRejected, $this->exception);
		}
	}

	return new static($this->handler, $this->queue);
}