Skip to content

Commit 7fcadc9

Browse files
authored
docs: (delay) add motivation sections (#349)
1 parent 1e21ded commit 7fcadc9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/delay/readme.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ import { delay } from 'patronum';
1111
import { delay } from 'patronum/delay';
1212
```
1313

14-
Method for delaying triggering given unit for some amount of time. Can accept `number`, `Store<number>` or `(sourceValue) => number` (function for calculating timeout based on `source` payload) as timeout. Exists in two form: shorthand `delay(source, timeout)` and object form `delay({source, timeout, target})`, the first one needs to create new unit for this specific purpose, last one needs when `target` unit is already exists and the goal is just to call it after delay
15-
1614
## `delay(source, timeout: number)`
1715

1816
:::note[since]
1917
patronum 2.1.0
2018
Use `delay({ source, timeout })` with patronum < 2.1.0
2119
:::
2220

21+
### Motivation
22+
23+
Method creates a new event that will be triggered after some time. It is useful for implementing timeouts, animations, or scheduling delayed operations.
24+
2325
### Formulae
2426

2527
```ts
@@ -55,6 +57,10 @@ trigger('hello');
5557

5658
## `delay({ source, timeout: number, target })`
5759

60+
### Motivation
61+
62+
This overload is useful when you already have a target unit that needs to be triggered with a delay.
63+
5864
### Formulae
5965

6066
```ts

0 commit comments

Comments
 (0)