Overview
TheokAsync function constructs a ResultAsync containing an Ok variant with the provided value.
Signature
The success value to wrap in a ResultAsync
ResultAsync<T, E> - A ResultAsync containing the Ok value
Usage
Basic usage
Async context
Chaining operations
When to use
- Starting an async operation that cannot fail
- Converting a successful value into a ResultAsync for consistency
- Creating test data with async operations
okAsync immediately wraps the value in a resolved Promise. For values that are already promises, use ResultAsync.fromSafePromise() instead.Related
errAsync
Create an Err variant of ResultAsync
ResultAsync.fromPromise
Create ResultAsync from a Promise