File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -29,15 +29,21 @@ greenlet(Function) -> Function
2929
3030## Example
3131
32+ Greenlet is most effective when the work being done has relatively small inputs/outputs.
33+
34+ One such example would be fetching a network resource when only a subset of the resulting information is needed:
35+
3236``` js
3337import greenlet from ' greenlet'
3438
35- let get = greenlet (async url => {
36- let res = await fetch (url)
37- return await res .json ()
39+ let getName = greenlet ( async username => {
40+ let url = ` https://api.github.com/users/${ username} `
41+ let res = await fetch (url)
42+ let profile = await res .json ()
43+ return profile .name
3844})
3945
40- console .log (await get ( ' /foo ' ))
46+ console .log (await getName ( ' developit ' ))
4147```
4248
4349
You can’t perform that action at this time.
0 commit comments