Skip to content

Latest commit

 

History

History
41 lines (34 loc) · 1.38 KB

README.md

File metadata and controls

41 lines (34 loc) · 1.38 KB

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.