Documentation ¶
Index ¶
- type Error
- type Panic
- type Promise
- func Call[T any](fn func() Result[T]) Promise[T]
- func Catch[T any](promise Promise[T], fn func(error) Result[T]) Promise[T]
- func New[T any]() (_ Promise[T], resolve func(T), reject func(error))
- func Rejected[T any](err error) Promise[T]
- func Resolved[T any](v T) Promise[T]
- func SyncCall[T any](mu sync.Locker, fn func() Result[T]) Promise[T]
- func SyncThen[T, S any](mu sync.Locker, promise Promise[T], fn func(T) Result[S]) Promise[S]
- func Then[T, S any](promise Promise[T], fn func(T) Result[S]) Promise[S]
- type Result
- type ResultPromise
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
Error is the Result of a failed process.
type Promise ¶
A Promise represents an asynchronous process.
func Catch ¶
Catch spawns a concurrent process that waits for the promise to resolve and calls the function if the promise fails, passing the result to the function.
func New ¶
New returns a Promise that behaves more like traditional promises, returning resolve and reject callbacks.
func SyncCall ¶
SyncCall spawns a process that acquires the lock, calls the function, and releases the lock.
type ResultPromise ¶
ResultPromise is a Promise that satisfies Result.
func (ResultPromise[T]) Get ¶
func (v ResultPromise[T]) Get() (T, error)
Get returns the result of the promise.
Click to show internal directories.
Click to hide internal directories.