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
Click to show internal directories.
Click to hide internal directories.