package promise
import "github.com/hack-pad/go-indexeddb/idb/internal/promise"
Package promise provides JavaScript Promise-like implementations
Index ¶
- func NewChan(ctx context.Context) (resolve, reject Resolver, promise Chan)
- type Chan
- func (c Chan) Await() (interface{}, error)
- func (c Chan) Catch(fn func(rejectedReason interface{}) interface{}) Promise
- func (c Chan) Then(fn func(value interface{}) interface{}) Promise
- type Promise
- type Resolver
Functions ¶
func NewChan ¶
NewChan creates a new Chan
Types ¶
type Chan ¶
type Chan struct {
// contains filtered or unexported fields
}
Chan is a Go channel-based promise
func (Chan) Await ¶
Await implements Promise
func (Chan) Catch ¶
Catch implements Promise
func (Chan) Then ¶
Then implements Promise
type Promise ¶
type Promise interface { Then(fn func(value interface{}) interface{}) Promise Catch(fn func(value interface{}) interface{}) Promise Await() (interface{}, error) }
Promise is a JS-like promise interface. Enables alternative implementations, like Go channels.
type Resolver ¶
type Resolver func(interface{})
Resolver can be returned from a new Promise constructor, great for resolving successes and failures with values.
Source Files ¶
- Version
- v0.3.0
- Published
- Jan 18, 2023
- Platform
- js/wasm
- Imports
- 2 packages
- Last checked
- 4 hours ago –
Tools for package owners.