Skip to content

Commit a216885

Browse files
committed
文档更新
1 parent 7085e8b commit a216885

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

docs/rhino/advanced/continuation.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# 协程
22

3-
见 App 中 `示例代码 / 协程`
4-
53
## Promise.coroutine()
64

75
**v6.3.7 新增**
@@ -42,3 +40,35 @@ main(10); //在控制台每秒输出一个数字
4240
- handler `{function}` 处理函数
4341

4442
函数的参数为 yield 的导出,反回值为 yield 的反回
43+
44+
## bluebird-co
45+
46+
[bluebird-co](https://github.com/novacrazy/bluebird-co) 是一个高效的 yield 处理程序,
47+
该处理程序可以转换与 [tj/co](https://github.com/tj/co) 所有相同的 yieldable 值类型以及更多。
48+
49+
使用
50+
51+
```js
52+
require('bluebird-co');
53+
var myAsyncFunction = Promise.coroutine(function*() {
54+
var results = yield [
55+
Promise.delay( 10 ).return( 42 ),
56+
Promise.resolve( "somefile contents" ),
57+
[1, Promise.resolve( 12 )]
58+
];
59+
console.log(results); //[42, "somefile contents", [1, 12]]
60+
});
61+
62+
myAsyncFunction().then(...);
63+
```
64+
65+
### Yieldable Types
66+
67+
- Promises
68+
- Arrays
69+
- Objects
70+
- Generators and GeneratorFunctions
71+
- Iterables (like new Set([1, 2, 3]).values())
72+
- Functions (as Thunks)
73+
- Custom data types via [.addYieldHandler(fn)#addyieldhandlerfn--function
74+
- Any combination or nesting of the above.

docs/rhino/vscode.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ npm i -D autox-v6-api
4040

4141
模板下载: [v6-project-webui-demo.zip](https://github.com/aiselp/AutoX/releases/tag/v7.1.2)
4242

43-
使用该模板需要配合 Autox 7.1.3 以上版本才可使用,下载模板后使用 vscode 打开,运行以下命令
43+
使用该模板需要配合 Autox 7.1.4 以上版本才可使用,下载模板后使用 vscode 打开,运行以下命令
4444

4545
```
4646
npm install

0 commit comments

Comments
 (0)