Skip to content

Commit 22aca95

Browse files
committed
Update readme
1 parent c8dfc00 commit 22aca95

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

readme.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,17 @@ npm add yieldmachine
2020
```javascript
2121
import { call, on, start } from "yieldmachine";
2222

23+
const exampleURL = new URL("https://example.org/");
24+
function fetchData() {
25+
return fetch(exampleURL.toString());
26+
}
27+
2328
function Loader({ url }) {
2429
function* idle() {
2530
yield on("FETCH", loading);
2631
}
2732
function* loading() {
28-
yield call(fetch, [url.toString()]);
33+
yield entry(fetchData);
2934
yield on("SUCCESS", success);
3035
yield on("FAILURE", failure);
3136
}
@@ -37,13 +42,13 @@ function Loader({ url }) {
3742
return idle;
3843
}
3944

40-
const loader = start(Loader, { url: new URL("https://example.org/") });
45+
const loader = start(Loader);
4146
loader.value; // "idle"
4247

4348
loader.next("FETCH");
4449
loader.value; // "loading"
4550

46-
loader.promisedValue.then(response => {
51+
loader.resolved.then(([response]) => {
4752
// Use response of fetch()
4853
loader.value; // "success"
4954
});

0 commit comments

Comments
 (0)