Documentation
¶
Index ¶
- type Promise
- func (p *Promise[T]) Err() error
- func (p *Promise[T]) IsEmpty() bool
- func (p *Promise[T]) OnComplete(callback func()) func()
- func (p *Promise[T]) OnError(callback func(err error)) func()
- func (p *Promise[T]) OnSuccess(callback func(result T)) (cancel func())
- func (p *Promise[T]) Reject(err error) *Promise[T]
- func (p *Promise[T]) Resolve(result T) *Promise[T]
- func (p *Promise[T]) Result() T
- func (p *Promise[T]) WaitComplete()
- func (p *Promise[T]) WasCompleted() bool
- func (p *Promise[T]) WasRejected() bool
- func (p *Promise[T]) WasResolved() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Promise ¶
type Promise[T any] struct { // contains filtered or unexported fields }
Promise is a promise that can be resolved or rejected.
func (*Promise[T]) Err ¶
Err returns the error of the promise (or nil if the promise was not rejected).
func (*Promise[T]) OnComplete ¶
func (p *Promise[T]) OnComplete(callback func()) func()
OnComplete registers a callback that is called when the promise is resolved or rejected.
func (*Promise[T]) OnError ¶
OnError registers a callback that is called when the promise is rejected.
func (*Promise[T]) OnSuccess ¶
func (p *Promise[T]) OnSuccess(callback func(result T)) (cancel func())
OnSuccess registers a callback that is called when the promise is resolved.
func (*Promise[T]) Result ¶
func (p *Promise[T]) Result() T
Result returns the result of the promise (or the zero value if the promise was not resolved).
func (*Promise[T]) WaitComplete ¶
func (p *Promise[T]) WaitComplete()
func (*Promise[T]) WasCompleted ¶
WasCompleted returns true if the promise was resolved or rejected.
func (*Promise[T]) WasRejected ¶
WasRejected returns true if the promise was rejected.
func (*Promise[T]) WasResolved ¶
WasResolved returns true if the promise was resolved.