You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/README.md
+34-2Lines changed: 34 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ In the world full of APIs, we starting to forget the power of plain JavaScript a
8
8
9
9
This project tends to use the simplicity of functional React components and the essential mechanism of coroutines to create stateful components with colocation.
10
10
11
+
## Usage
11
12
12
13
```javascript
13
14
importReactfrom'react';
@@ -18,15 +19,46 @@ import PostList from 'PostList.react';
18
19
asyncfunctionPostListCo() {
19
20
try {
20
21
constposts=awaitPosts.retrieve();
21
-
return<PostList posts={posts} />;
22
+
return<PostList posts={posts} />
22
23
} catch (error) {
23
-
return<p>Unable to fetch posts.</p>;
24
+
return<p>Unable to fetch posts.</p>
24
25
}
25
26
}
26
27
27
28
exportdefaultCoroutine.create(PostListCo);
28
29
```
29
30
31
+
### Dependency injection
32
+
33
+
For the sake of testability you might want to inject instances into your coroutine in the way how React `props` are provided.
34
+
35
+
You are able to provide `getVariables()` function that receives `props` and `context` and returns an object that will be passed in a coroutine.
0 commit comments