-
-
Notifications
You must be signed in to change notification settings - Fork 751
Open
Description
The TypeScript types of the effect functions could be improved:
-
hopeThat
According to the source code, this function:
- does not accept an asynchronous callback -- is this intentional?
- does not use the result of the callback
- returns a success flag
Therefore, it can be made non-generic and with a synchronous callback.
- type HopeThat = <T>(fn: () => Promise<T> | T) => Promise<T | false>; + type HopeThat = (fn: () => void) => Promise<boolean>;
-
tryTo
According to the source code, this function:
- does not accept an asynchronous callback -- is this intentional?
- does not use the result of the callback
- returns a success flag
Therefore, it can be made non-generic and with a synchronous callback.
- type TryTo = <T>(fn: () => Promise<T> | T) => Promise<T | false>; + type TryTo = (fn: () => void) => Promise<boolean>;
-
retryTo
According to the source code, this function:
- expects "maxTries" to be defined
- accepts optional "pollIntervall"
- passes iteration index to callback
- does not use the result of the callback
- returns a success flag
Therefore, it can be made non-generic with an extended signature.
- type RetryTo = <T>(fn: () => Promise<T> | T, retries?: number) => Promise<T>; + type RetryTo = (fn: (tries: number) => Promise<void> | void, maxTries: number, pollInterval?: number) => Promise<boolean>;
I would open a PR if intended support for asynchronous callbacks in hopeThat
and tryTo
is clear.
ivan-guschin-rs
Metadata
Metadata
Assignees
Labels
No labels