React/Promise
=============
A lightweight implementation of
[CommonJS Promises/A](http://wiki.commonjs.org/wiki/Promises/A) for PHP.
[![Build Status](https://travis-ci.org/reactphp/promise.svg?branch=master)](http://travis-ci.org/reactphp/promise)
[![Coverage Status](https://coveralls.io/repos/github/reactphp/promise/badge.svg?branch=master)](https://coveralls.io/github/reactphp/promise?branch=master)
Table of Contents
-----------------
1. [Introduction](#introduction)
2. [Concepts](#concepts)
* [Deferred](#deferred)
* [Promise](#promise)
3. [API](#api)
* [Deferred](#deferred-1)
* [Deferred::promise()](#deferredpromise)
* [Deferred::resolve()](#deferredresolve)
* [Deferred::reject()](#deferredreject)
* [Deferred::notify()](#deferrednotify)
* [PromiseInterface](#promiseinterface)
* [PromiseInterface::then()](#promiseinterfacethen)
* [ExtendedPromiseInterface](#extendedpromiseinterface)
* [ExtendedPromiseInterface::done()](#extendedpromiseinterfacedone)
* [ExtendedPromiseInterface::otherwise()](#extendedpromiseinterfaceotherwise)
* [ExtendedPromiseInterface::always()](#extendedpromiseinterfacealways)
* [ExtendedPromiseInterface::progress()](#extendedpromiseinterfaceprogress)
* [CancellablePromiseInterface](#cancellablepromiseinterface)
* [CancellablePromiseInterface::cancel()](#cancellablepromiseinterfacecancel)
* [Promise](#promise-1)
* [FulfilledPromise](#fulfilledpromise)
* [RejectedPromise](#rejectedpromise)
* [LazyPromise](#lazypromise)
* [Functions](#functions)
* [resolve()](#resolve)
* [reject()](#reject)
* [all()](#all)
* [race()](#race)
* [any()](#any)
* [some()](#some)
* [map()](#map)
* [reduce()](#reduce)
* [PromisorInterface](#promisorinterface)
4. [Examples](#examples)
* [How to use Deferred](#how-to-use-deferred)
* [How promise forwarding works](#how-promise-forwarding-works)
* [Resolution forwarding](#resolution-forwarding)
* [Rejection forwarding](#rejection-forwarding)
* [Mixed resolution and rejection forwarding](#mixed-resolution-and-rejection-forwarding)
* [Progress event forwarding](#progress-event-forwarding)
* [done() vs. then()](#done-vs-then)
5. [Credits](#credits)
6. [License](#license)
Introduction
------------
React/Promise is a library implementing
[CommonJS Promises/A](http://wiki.commonjs.org/wiki/Promises/A) for PHP.
It also provides several other useful promise-related concepts, such as joining
multiple promises and mapping and reducing collections of promises.
If you've never heard about promises before,
[read this first](https://gist.github.com/3889970).
Concepts
--------
### Deferred
A **Deferred** represents a computation or unit of work that may not have
completed yet. Typically (but not always), that computation will be something
that executes asynchronously and completes at some point in the future.
### Promise
While a deferred represents the computation itself, a **Promise** represents
the result of that computation. Thus, each deferred has a promise that acts as
a placeholder for its actual result.
API
---
### Deferred
A deferred represents an operation whose resolution is pending. It has separate
promise and resolver parts.
```php
$deferred = new React\Promise\Deferred();
$promise = $deferred->promise();
$deferred->resolve(mixed $value = null);
$deferred->reject(mixed $reason = null);
$deferred->notify(mixed $update = null);
```
The `promise` method returns the promise of the deferred.
The `resolve` and `reject` methods control the state of the deferred.
The `notify` method is for progress notification.
The constructor of the `Deferred` accepts an optional `$canceller` argument.
See [Promise](#promise-1) for more information.
#### Deferred::promise()
```php
$promise = $deferred->promise();
```
Returns the promise of the deferred, which you can hand out to others while
keeping the authority to modify its state to yourself.
#### Deferred::resolve()
```php
$deferred->resolve(mixed $value = null);
```
Resolves the promise returned by `promise()`. All consumers are notified by
having `$onFulfilled` (which they registered via `$promise->then()`) called with
`$value`.
If `$value` itself is a promise, the promise will transition to the state of
this promise once it is resolved.
#### Deferred::reject()
```php
$deferred->reject(mixed $reason = null);
```
Rejects the promise returned by `promise()`, signalling that the deferred's
computation failed.
All consumers are notified by having `$onRejected` (which they registered via
`$promise->then()`) called with `$reason`.
If `$reason` itself is a promise, the promise will be rejected with the outcome
of this promise regardless whether it fulfills or rejects.
#### Deferred::notify()
```php
$deferred->notify(mixed $update = null);
```
Triggers progress notifications, to indicate to consumers that the computation
is making progress toward its result.
All consumers are notified by having `$onProgress` (which they registered via
`$promise->then()`) called with `$update`.
### PromiseInterface
The promise interface provides the common interface for all promise
implementations.
A promise represents an eventual outcome, which is either fulfillment (success)
and an associated value, or rejection (failure) and an associated reason.
Once in the fulfilled or rejected state, a promise becomes immutable.
Neither its state nor its result (or error) can be modified.
#### Implementations
* [Promise](#promise-1)
* [FulfilledPromise](#fulfilledpromise)
* [RejectedPromise](#rejectedpromise)
* [LazyPromise](#lazypromise)
#### PromiseInterface::then()
```php
$transformedPromise = $promise->then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null);
```
Transforms a promise's value by applying a function to the promise's fulfillment
or rejection value. Returns a new promise for the transformed result.
The `then()` method registers new fulfilled, rejection and progress handlers
with a promise (all parameters are optional):
* `$onFulfilled` will be invoked once the promise is fulfilled and passed
the result as the first argument.
* `$onRejected` will be invoked once the promise is rejected and passed the
reason as the first argument.
* `$onProgress` will be invoked whenever the producer of the promise
triggers progress notifications and passed a single argument (whatever it
wants) to indicate progress.
It returns a new promise that will fulfill with the return value of either
`$onFulfilled` or `$onRejected`, whichever is called, or will reject with
the thrown exception if either throws.
A promise makes the following guarantees about handlers registered in
the same call to `then()`:
1. Only one of `$onFulfilled` or `$onRejected` will be called,
never both.
2. `$onFulfilled` and `$onRejected` will never be called more
than once.
3. `$onProgress` may be called multiple times.
#### See also
* [resolve()](#resolve) - Creating a resolved promise
* [reject()](#reject) - Creating a rejected promise
* [ExtendedPromiseInterface::done()](#extendedpromiseinterfacedone)
* [done() vs. then()](#done-vs-then)
### ExtendedPromiseInterface
The ExtendedPromiseInterface extends the PromiseInterface with useful shortcut
and utility methods which are not part of the Promises/A specification.
#### Implementations
* [Promise](#promise-1)
* [FulfilledPromise](#fulfilledpromise)
* [RejectedPromise](#rejectedpromise)
* [LazyPromise](#lazypromise)
#### ExtendedPromiseInterface::done()
```php
$promise->done(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null);
```
Consumes the promise's ultimate value if the promise fulfills, or handles the
ultimate error.
It will cause a fatal error if either `$onFulfilled` or `$onRejected` throw or
return a rejected promise.
Since the purpose of `done()` is c
没有合适的资源?快使用搜索试试~ 我知道了~
音乐发行平台音乐网站系统开源音乐网站统源码
共2000个文件
php:1076个
html:231个
png:151个
5星 · 超过95%的资源 需积分: 5 14 下载量 73 浏览量
2022-09-05
10:32:33
上传
评论 2
收藏 13.48MB ZIP 举报
温馨提示
php 版本必须 5.4 或更高 ,MySQL(5.1以上) PHP需开启 curl 扩展 pdo 扩展 支持Windows/Unix服务器环境 可运行于包括Apache、IIS和nginx在内的多种WEB服务器和模式 程序模板使用html5+css3开发 必须在支持html5的浏览器打开 推荐 IE9 + 、 谷歌 、火狐浏览器! 安装方法 ├─ addons 目录(包括子目录)必须有可写权限 ├─ config 文件夹 必须有可写权限├─ app 文件夹(包括子目录) 必须有可写权限├─ resources 目录(包括子目录)必须有可写权限├─ storage 文件夹 必须有可写权限├─ uploads 文件夹以及子目录必须有可写权限 使用 FTP 软件登录您的服务器,将服务器上以上目录、以及该指定目录下面的所有文件的属性设置为 777,Win 主机请设置internet 来宾帐户可读写属性 开始安装 安装完成后删除数据库在导入1.sql数据库即可恢复正常使用
资源推荐
资源详情
资源评论
收起资源包目录
音乐发行平台音乐网站系统开源音乐网站统源码 (2000个子文件)
无限数字音乐.apk 4.57MB
config 490B
js_composer.min.css 474KB
public-styles.min.css 340KB
style.min.css 159KB
bootstrap.min.css 118KB
style.min.css 87KB
app.css 85KB
websitebox_index.css 84KB
cnm.sb_bg.css 74KB
app.min.css 65KB
pages.css 46KB
components.css 44KB
style.css 41KB
style.css 41KB
core.css 38KB
wbp_contact.css 27KB
style.css 22KB
cnm.sb_pc.css 21KB
font-awesome.min.css 20KB
swiper.min.css 19KB
swiper.min.css 19KB
layer.css 19KB
layer.css 19KB
wangEditor.min.css 18KB
avatar.css 18KB
dynamic-styles.css 18KB
swiper.min.css 17KB
jy.css 16KB
animate.css 16KB
plugs.css 14KB
plugs.css 14KB
sweet-alert.css 12KB
comment.css 12KB
plugs.min.css 12KB
plugs.min.css 12KB
style.css 11KB
slider.css 11KB
cnm.sb_mp.css 10KB
user.css 9KB
user.css 9KB
index.css 9KB
boot.css 9KB
usera.css 9KB
usera.css 9KB
api.css 8KB
api.css 8KB
header.css 8KB
toastr.css 8KB
jymusic.fileupload.css 7KB
magnific-popup.css 7KB
pressapps-modal-login-public.css 6KB
article.css 6KB
article.css 6KB
jyplayer.css 6KB
aliicon.css 5KB
wbui.css 5KB
player.css 5KB
player.css 5KB
main.css 4KB
cropper.min.css 4KB
tree.css 4KB
awesome-bootstrap-checkbox.css 4KB
play.css 4KB
play.css 4KB
responsive.css 2KB
login.css 2KB
responsive.css 2KB
elementor.min.css 2KB
pay.css 2KB
reg.css 2KB
style.css 1KB
admin-popup.css 1KB
jquery.loading.min.css 1KB
bootstrap-tagsinput.css 1KB
css.css 620B
cnm.sb_load.css 525B
labels.css 429B
page.css 32B
description 73B
phpunit.xml.dist 834B
phpunit.xml.dist 831B
phpunit.xml.dist 830B
phpunit.xml.dist 830B
phpunit.xml.dist 770B
phpunit.xml.dist 563B
phpunit.xml.dist 557B
phpunit.xml.dist 460B
phpunit.xml.dist 447B
phpunit.xml.dist 355B
.empty 0B
fontawesome-webfont.eot 162KB
iconfont.eot 83KB
fontawesome-webfont.eot 71KB
ep_icons.eot 66KB
glyphicons-halflings-regular.eot 20KB
icomoon.eot 15KB
vcpb-plugin-icons.eot 7KB
vc_grid_v1.eot 6KB
other-file.example 0B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
「已注销」
- 粉丝: 16
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- nuget 库官方下载包,可使用解压文件打开解压使用
- 非wine、原生Linux迅雷安装包deb文件,支持Ubuntu、UOS统信、深度Deepin、LinuxMint、Debain系通用
- KUKA机器人安装包,与PROFINET软件包
- 船舶燃料消耗和二氧化碳排放分析数据集,燃料消耗和碳排放关联分析数据
- req-sign、bd-ticket-ree-public加密算法(JS)
- 全自动批量建站快速养权重站系统【纯静态html站群版】:(GPT4.0自动根据关键词写文章+自动发布+自定义友链+自动文章内链+20%页面加提权词)
- 串联式、并联式、混联式混合动力系统simulink控制策略模型(串联式、并联式、混联式每个都是独立的需要单独说拿哪个,默认是混联式RB) 有基于逻辑门限值、状态机的规则控制策略(RB)、基于等效燃油
- 法码滋.exe法码滋2.exe法码滋3.exe
- python-geohash-0.8.5-cp38-cp38-win-amd64
- Matlab根据flac、pfc或其他软件导出的坐标及应力、位移数据再现云图 案例包括导出在flac6.0中导出位移的fish代码(也可以自己先准备软件导出的坐标数据及对应点的位移或应力数据,可根据需
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页