You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 99b1ecc
Browse filesBrowse the repository at this point in the historyBrowse files
`RightAsyncPipeFunction` receives the unwrapped value of a `Right` (after `await`) and can return a raw value, an `Either`, or a promise/Future of these values.
42
+
`RightAsyncPipeFunction` receives the unwrapped value of a `Right` (after `await`) and can return a raw value, an `Either`, or a promise of these values.
38
43
39
44
## Parameters
40
45
41
-
-`input`: Starting `Either`, promise, or `Future`.
46
+
-`input`: Starting value, `Either`, or promise.
42
47
-`pipeX`: Async or sync functions executed sequentially. The pipeline stops on the first `Left`.
43
48
44
49
## Return value
45
50
46
-
A `Future` resolved with the last `Right` if everything succeeds, or the `Left` that interrupted the pipeline.
51
+
A `Promise` resolved with the last `Right` if everything succeeds, or the `Left` that interrupted the pipeline.
47
52
48
53
## Best practices
49
54
50
55
- Prefix your information with a clear namespace (`"user.fetch"`, `"user.validate"`) to track progress.
51
56
- Combine `rightAsyncPipe` and `rightPipe` depending on whether your steps are sync/async.
52
-
-In a `Promise`/`Future` mix, let `rightAsyncPipe` handle the normalization.
57
+
-Let `rightAsyncPipe` await each step instead of manually unwrapping intermediate promises.
53
58
54
59
## See also
55
60
56
61
-[`rightPipe`](/en/v1/api/either/rightPipe).
57
-
-[`future`](/en/v1/api/either/future) – To create `Future` values to chain.
62
+
-[`safeCallback`](/en/v1/api/either/safeCallback) – To convert thrown errors into `Either` values.
description: "Runs a callback in a safe block. If the callback throws, the function returns a \"callback\" typed Left instead of propagating the exception."
3
+
description: "Runs a callback in a safe block. If the callback throws or returns a rejected promise, the function returns or resolves to a safe-callback-error Left instead of propagating the error."
4
4
prev:
5
5
text: "expect"
6
6
link: "/en/v1/api/either/expect"
@@ -11,37 +11,38 @@ next:
11
11
12
12
# safeCallback
13
13
14
-
Runs a callback in a safe block. If the callback throws, the function returns a `"callback"` typed `Left` instead of propagating the exception. If the callback returns an `Either`, it is kept as-is.
14
+
Runs a callback in a safe block. If the callback throws or returns a rejected promise, the function returns or resolves to a `"safe-callback-error"` typed `Left` instead of propagating the error. If the callback returns an `Either`, it is kept as-is. Promise results are handled after resolution.
0 commit comments