Skip to content

go-zoox/promise

Repository files navigation

Promise - JavaScript Promise Like with Goroutines

PkgGoDev Build Status Go Report Card Coverage Status GitHub issues Release

Installation

To install the package, run:

go get github.com/go-zoox/promise

Getting Started

func main() {
	p := New(func(resolve Resolver, reject Rejecter) {
		time.Sleep(100 * time.Millisecond)
		resolve(1)
	})

	p.Then(func(v interface{}) interface{} {
		return v.(int) + 1
	}).Then(func(v interface{}) interface{} {
		return v.(int) * 2
	}).Catch(func(err error) {
		promiseErr = err
	})

	res, err := p.Wait()
	if err != nil {
		t.Error(err)
	}
}

License

GoZoox is released under the MIT License.

About

JavaScript Promise Like with Goroutines

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages