本文整理汇总了Golang中github.com/augustoroman/promise.Promise.Resolve方法的典型用法代码示例。如果您正苦于以下问题:Golang Promise.Resolve方法的具体用法?Golang Promise.Resolve怎么用?Golang Promise.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/augustoroman/promise.Promise
的用法示例。
在下文中一共展示了Promise.Resolve方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Register
func (d *Domain) Register(endpoint string, handler *js.Object) *js.Object {
cb := core.NewID()
var p promise.Promise
go func() {
// From the want wrapper pull out the types they defined,
// and pass them down into the core.
h := handler.Get("types")
tmp := h.Interface()
types, hasTypes := tmp.([]interface{})
// handler can either be:
// 1. an object that contains "types" and "fp" attributes.
// 2. a naked function, in which case we tell the core that it doesn't
// care about types.
handlerFunction := handler
handlerTypes := []interface{}{nil}
if hasTypes {
handlerFunction = handler.Get("fp")
handlerTypes = types
}
if err := d.coreDomain.Register(endpoint, cb, handlerTypes); err == nil {
d.app.registrations[cb] = handlerFunction
p.Resolve(nil)
} else {
p.Reject(err)
}
}()
return p.Js()
}
示例2: promisify
// Turn the given invocation into a JS promise. If the function returns an error, return the error,
// else return the results of the function
func promisify(fn func() (interface{}, error)) *js.Object {
var p promise.Promise
go func() {
if results, err := fn(); err == nil {
p.Resolve(results)
} else {
p.Reject(err.Error())
}
}()
return p.Js()
}
示例3: Leave
func (d *Domain) Leave() *js.Object {
var p promise.Promise
go func() {
if err := d.coreDomain.Leave(); err == nil {
p.Resolve(nil)
} else {
p.Reject(err)
}
}()
return p.Js()
}
示例4: Unregister
func (d *Domain) Unregister(endpoint string) *js.Object {
var p promise.Promise
go func() {
if err := d.coreDomain.Unregister(endpoint); err == nil {
p.Resolve(nil)
} else {
p.Reject(err)
}
}()
return p.Js()
}
示例5: Call
func (d *Domain) Call(endpoint string, args ...interface{}) *js.Object {
var p promise.Promise
go func() {
if results, err := d.coreDomain.Call(endpoint, args, make([]interface{}, 0)); err == nil {
p.Resolve(results)
} else {
p.Reject(err.Error())
}
}()
return p.Js()
}
示例6: Publish
func (d *Domain) Publish(endpoint string, args ...interface{}) *js.Object {
var p promise.Promise
go func() {
if err := d.coreDomain.Publish(endpoint, args); err == nil {
p.Resolve(nil)
} else {
p.Reject(err)
}
}()
return p.Js()
}
示例7: Register
func (d *Domain) Register(endpoint string, handler *js.Object) *js.Object {
cb := core.NewID()
var p promise.Promise
go func() {
if err := d.coreDomain.Register(endpoint, cb, make([]interface{}, 0)); err == nil {
d.app.registrations[cb] = handler
p.Resolve(nil)
} else {
p.Reject(err)
}
}()
return p.Js()
}