promise

package
v0.0.0-...-3fd3bf7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2022 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorPromise

type ErrorPromise struct {
	*SyncPromise[struct{}, error]
}

error promise

func NewErrorPromise

func NewErrorPromise(callback func() error) *ErrorPromise

func (*ErrorPromise) Catch

func (p *ErrorPromise) Catch(callback func(error))

func (*ErrorPromise) Then

func (p *ErrorPromise) Then(callback func() error) *ErrorPromise

type SyncPromise

type SyncPromise[Resolve any, Reject any] struct {
	IsReject func(Reject) bool // judge whether T is rejected data
	// contains filtered or unexported fields
}

-------Async Promise

func NewSyncPromise

func NewSyncPromise[Res any, Rej any](isrej func(Rej) bool, callback func() (Res, Rej)) *SyncPromise[Res, Rej]

func (*SyncPromise[Res, Rej]) Catch

func (p *SyncPromise[Res, Rej]) Catch(callback func(Rej))

func (*SyncPromise[Res, Rej]) Then

func (p *SyncPromise[Res, Rej]) Then(callback func(Res) (Res, Rej)) *SyncPromise[Res, Rej]

give a callback function that accepts data and returns next data data should be able to judge whether it's rejected

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL