Conversation
commit: |
Co-authored-by: Taras Mankovski <tarasm@gmail.com>
cowboyd
left a comment
There was a problem hiding this comment.
There are some where I'm not so sure we need examples. Or if we do have them, they should be very, very concise.
| * function useValue() { | ||
| * return resource(function* (provide: Provide<number>) { | ||
| * yield* provide(42); | ||
| * }); | ||
| * } | ||
| * | ||
| * console.log(yield* useValue()); // 42 | ||
| * | ||
| * // alternatively, the preferred pattern is | ||
| * function useValue() { | ||
| * return resource<number>(function* (provide) { | ||
| * yield* provide(42); | ||
| * }); | ||
| * } |
There was a problem hiding this comment.
This example doesn't provide much. A resource is about acquisition and release and so any example should demonstrate those two things. A connection pool maybe?
There was a problem hiding this comment.
I was trying not to complicate it too much, but I see the point. The main intent was for folks that land on this API page trying to understand what the value of provide is.
https://frontside.com/effection/api/v4/Provide/
Is it valid to have an expectation that they arrive there having already looked at the value of using a resource? Maybe just a simple comment or something saying as such?
There was a problem hiding this comment.
I think they will most likely arrive by hovering on a parameter resource() so could definitely be like "what is this?"
There was a problem hiding this comment.
I updated it. What do you think of this?
Motivation
Filling out the JSDocs a bit more. These show up both on the website, but also in IDEs.
Closes #1139.
Approach
Fix a few broken bits, and add more examples.