Ejemplo n.º 1
0
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()
}
Ejemplo n.º 2
0
Archivo: main.go Proyecto: newgogo/Exis
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()
}
Ejemplo n.º 3
0
Archivo: main.go Proyecto: newgogo/Exis
//export CBID
func CBID() uint64 {
	return core.NewID()
}