@@ -27,70 +27,7 @@ export default Coroutine.create(UserListContainer);
2727
2828## Usage
2929
30- Inject variables to a coroutine:
30+ See [ docs ] ( ./docs/ ) for more.
3131
32- ``` javascript
33- function getVariables (props ) {
34- return {
35- posts: new PostsDAO (props .userId ),
36- };
37- }
38-
39- async function PostListContainer ({ posts }) {
40- try {
41- return < PostList posts= {await posts .retrieve ()} / >
42- } catch (error) {
43- return < ErrorMessage error= {error} / >
44- }
45- }
46-
47- export default Coroutine .create (PostListCo, getVariables);
48- ```
49-
50- And use it as a component:
51-
52- ``` javascript
53- < PostListContainer userId= {... } / >
54- ```
55-
56- Async generators as components:
57-
58- ``` javascript
59- async function * CommentListContainer () {
60- yield < LoadingSpinner / > ;
61-
62- try {
63- const comments = await CommentsDAO .retrieve ();
64- return < CommentList comments= {comments} / > ;
65- } catch (error) {
66- return < ErrorMessage error= {error} / > ;
67- }
68- }
69-
70- export default Coroutine .create (CommentListContainer);
71- ```
72-
73- ``` javascript
74- async function * EventStreamContainer () {
75- for await (const message of dispatcher ) {
76- yield < p> Last message {message .type }< / p> ;
77- }
78- }
7932
80- export default Coroutine .create (EventStreamContainer);
81- ```
8233
83- ``` javascript
84- async function * List () {
85- try {
86- const items = await Items .retrieve ();
87- yield < ItemList items= {items} / > ;
88- const additionalInfo = await Info .retrieve ();
89- return < ItemList items= {items} info= {info} / > ;
90- } catch (error) {
91- return < p> ... < / p> ;
92- }
93- }
94-
95- export default Coroutine .create (List);
96- ```
0 commit comments