Skip to content

Commit

Permalink
docs(README.md): fix code problem
Browse files Browse the repository at this point in the history
fix demo code problems

fix alibaba#10
  • Loading branch information
pengyutang125 committed Mar 1, 2019
1 parent d095fd7 commit 18d21a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ The above code turns the code that originally needs dispatch_async twice into se

In the coroutine, all our methods are directly returning the value, and no error is returned. Our error in the execution process is obtained by co_getError(). For example, we have the following interface to obtain data from the network. When the promise will reject: error<br /><br />
```
- (CCOPromise*)co_GET:(NSString*)url parameters:(NSDictionary*)parameters{
CCOPromise *promise = [CCOPromise promise];
- (COPromise*)co_GET:(NSString*)url parameters:(NSDictionary*)parameters{
COPromise *promise = [COPromise promise];
[self GET:url parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[promise fulfill:responseObject];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
Expand Down Expand Up @@ -185,10 +185,10 @@ Through the generator, we can load the data from the traditional producer--notif
We can use co_actor_onqueue to create an actor in the specified thread.

```
CCOActor *actor = co_actor_onqueue(q, ^(CCOActorChan *channel) {
COActor *actor = co_actor_onqueue(q, ^(COActorChan *channel) {
... //Define the state variable of the actor
for(CCOActorMessage *message in channel){
for(COActorMessage *message in channel){
...//handle message
}
});
Expand All @@ -199,10 +199,10 @@ CCOActor *actor = co_actor_onqueue(q, ^(CCOActorChan *channel) {
The actor's send method can send a message to the actor

```
CCOActor *actor = co_actor_onqueue(q, ^(CCOActorChan *channel) {
COActor *actor = co_actor_onqueue(q, ^(COActorChan *channel) {
... //Define the state variable of the actor
for(CCOActorMessage *message in channel){
for(COActorMessage *message in channel){
...//handle message
}
});
Expand Down
12 changes: 6 additions & 6 deletions README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ co_launch(^{
在协程中,我们所有的方法都是直接返回值的,并没有返回错误,我们在执行过程中的错误是通过 `co_getError()` 获取的,比如我们有以下从网络获取数据的接口,在失败的时候, promise 会 `reject:error`<br /><br />

```objc
- (CCOPromise*)co_GET:(NSString*)url
- (COPromise*)co_GET:(NSString*)url
parameters:(NSDictionary*)parameters{
CCOPromise *promise = [CCOPromise promise];
COPromise *promise = [COPromise promise];
[self GET:url parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[promise fulfill:responseObject];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
Expand Down Expand Up @@ -170,9 +170,9 @@ co(^{
我们可以使用 `co_actor_onqueue` 在指定线程创建 actor

```objc
CCOActor *actor = co_actor_onqueue(^(CCOActorChan *channel) {
COActor *actor = co_actor_onqueue(^(COActorChan *channel) {
... //定义 actor 的状态变量
for(CCOActorMessage *message in channel){
for(COActorMessage *message in channel){
...//处理消息
}
}, q);
Expand All @@ -183,9 +183,9 @@ CCOActor *actor = co_actor_onqueue(^(CCOActorChan *channel) {
actor 的 `send` 方法可以给 actor 发送消息

```objc
CCOActor *actor = co_actor_onqueue(^(CCOActorChan *channel) {
COActor *actor = co_actor_onqueue(^(COActorChan *channel) {
... //定义actor的状态变量
for(CCOActorMessage *message in channel){
for(COActorMessage *message in channel){
...//处理消息
}
}, q);
Expand Down

0 comments on commit 18d21a4

Please sign in to comment.