Skip to content

Commit

Permalink
增加自定义并发数功能
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengjunxin committed May 20, 2017
1 parent 04ba759 commit 93f1b37
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
![](https://img.shields.io/badge/platform-Wechat-44cb11.svg)

# wx-promise-request
wx-promise-request 是对微信小程序 `wx.request` 方法的异步封装
wx-promise-request 是微信小程序 `wx.request` 方法的不支持 Promise 和并发数问题的解决方案

## 解决问题
- 支持 Promise (使用 [es6-promise](https://github.com/stefanpenner/es6-promise) 库)。
- 管理请求队列,解决 request 最大并发数超过 10 会报错的问题。

## 下载
由于小程序不支持 node_modules,所以直接下载 [index.js](https://joezheng2015.github.io/wx-promise-request/dist/index.js) 文件即可
由于小程序不支持 npm,所以直接右键保存 [index.js](https://joezheng2015.github.io/wx-promise-request/dist/index.js) 文件即可

## 使用
``` javascript
Expand All @@ -32,7 +32,11 @@ request({
## API
setConfig(object)

通过 setConfig 配置 wx-promise-request,如:使用 qcloud 提供的 request 方法;使用其他 Promise 库等等。
可以通过 setConfig 配置 wx-promise-request 如:
- 使用 qcloud 提供的 request 方法
- 使用其他 Promise 库
- 自定义并发数

``` javascript
import {request, setConfig} from './wx-promise-request';
import qcloud from './vendor/qcloud-weapp-client-sdk/index';
Expand All @@ -41,6 +45,7 @@ import Promise from 'bluebird';
setConfig({
request: qcloud.request,
Promise,
concurrency: 5,
})
request({
url: 'test.php',
Expand Down
Loading

0 comments on commit 93f1b37

Please sign in to comment.