Skip to content

Commit 607e78d

Browse files
committed
Document .value
1 parent 43be5de commit 607e78d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

readme.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ function Switch() {
7979
}
8080
```
8181

82-
Now our machine is ready to be run. We pass our `Switch` to the `start` function we import from `yieldmachine`, and it will run an instance of our machine. And as we send it `"FLICK"` message, you’ll see the `current` state of our machine instance change.
82+
Now our machine is ready to be run. We pass our `Switch` to the `start` function we import from `yieldmachine`, and it will run an instance of our machine. And as we send it `"FLICK"` message, you’ll see the `value` of our machine instance change.
8383

8484
```ts
8585
const machine = start(Switch);
86-
machine.current; // "Off"
86+
machine.value; // { state: "Off", change: 0 }
8787
machine.next("FLICK");
88-
machine.current; // "On"
89-
machine.next("TOGGLE");
90-
machine.current; // "Off"
88+
machine.value; // { state: "On", change: 1 }
89+
machine.next("FLICK");
90+
machine.value; // { state: "Off", change: 2 }
9191
```
9292

9393
## Benefits of Generator Functions
@@ -106,17 +106,19 @@ machine.current; // "Off"
106106

107107
Starts a machine, transitioning to its initially returned state.
108108

109-
### `.current: string | Record<string, unknown>`
109+
### `.value`
110+
111+
#### `.value.state: string | Record<string, unknown>`
110112

111113
The current state of the machine. If machines were nested then an object is returned with the parent machine as the key, and its current state as the value.
112114

113-
### `.changeCount: number`
115+
#### `.value.change: number`
114116

115117
The number of times this machine has transitioned. Useful for consumers updating only when changes have been made.
116118

117-
### `.results: Promise<unknown>`
119+
#### `.value.results: Promise<unknown>`
118120

119-
The result of any `entry()` or `exit()` messages.
121+
The result of calling functions passed to `entry()` or `exit()`.
120122

121123
### `.next(eventName: string | symbol)`
122124

0 commit comments

Comments
 (0)