Documentation
¶
Index ¶
- func Inspect(typ reflect.Type) (reflect.Type, bool)
- type Deferred
- type Promise
- func All[T any](promises ...*Promise[T]) *Promise[[]T]
- func Any[T any](promises ...*Promise[T]) *Promise[T]
- func Catch[T any](promise *Promise[T], rejection func(err error) error) *Promise[T]
- func Coerce[T any](promise *Promise[any]) *Promise[T]
- func Delay(delay time.Duration) *Promise[Void]
- func New[T any](executor func(resolve func(T), reject func(error))) *Promise[T]
- func Race[T any](promises ...*Promise[T]) *Promise[T]
- func Reject[T any](err error) *Promise[T]
- func Resolve[T any](resolution T) *Promise[T]
- func Then[A, B any](promise *Promise[A], resolveA func(data A) B) *Promise[B]
- func Unwrap[T any](promise *Promise[*Promise[T]]) *Promise[T]
- func (p *Promise[T]) Await() (T, error)
- func (p *Promise[T]) AwaitAny() (any, error)
- func (p *Promise[T]) Catch(rej func(err error) error) *Promise[any]
- func (p *Promise[T]) Coerce(promise *Promise[any])
- func (p *Promise[T]) Lift(result any)
- func (p *Promise[T]) Then(res func(data any) any) *Promise[any]
- func (p *Promise[T]) UnderlyingType() reflect.Type
- type Reflect
- type Void
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Deferred ¶
type Deferred[T any] struct { // contains filtered or unexported fields }
Deferred represents the computation that fulfills a Promise.
type Promise ¶
type Promise[T any] struct { // contains filtered or unexported fields }
Promise represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
func All ¶
All resolves when all the input's promises have resolved. All rejects immediately upon any of the input promises rejecting. All returns nil if the input is empty.
func Any ¶
Any resolves as soon as any of the input's Promises resolve, with the value of the resolved Promise. Any rejects if all the given Promises are rejected with a combination of all errors. Any returns nil if the input is empty.
func Catch ¶
Catch allows to chain promises. Use it to add an error handler to the rejected promise.
func Race ¶
Race resolves or rejects as soon as one of the input's Promises resolve or reject, with the value or error of that Promise. Race returns nil if the input is empty.