Skip to content

Commit f1148a0

Browse files
committed
Improve docs
1 parent f24104f commit f1148a0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

readme.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,24 @@ Sends an event to the machine, transitioning if the event was recognised. Unreco
4141

4242
### `on(eventName: string | symbol, target: GeneratorFunction)`
4343

44+
Transitions to the target state when the given event occurs.
45+
4446
### `enter(action: () => undefined | unknown | Promise<unknown>)`
4547

48+
Runs the provided function when this state is entered. If the function returns a promise, its value is made available in the `.results` property of the machine, keyed by the name of this passed function.
49+
4650
### `exit(action: () => undefined | unknown | Promise<unknown>)`
4751

52+
Runs the provided function when this state is exited.
53+
4854
### `cond(predicate: () => boolean, target: GeneratorFunction)`
4955

56+
Immediately transitions to the target state if the provided predicate function returns `true`.
57+
5058
### `always(target: GeneratorFunction)`
5159

60+
Immediately transitions to the target state, if previous `cond()` did not pass.
61+
5262
### `listenTo(sender: EventTarget, eventName: string)`
5363

5464
Listens to an `EventTarget` — for example, an HTMLElement like a button.

0 commit comments

Comments
 (0)