当前位置: 首页>>代码示例>>Golang>>正文


Golang Object.Invoke方法代码示例

本文整理汇总了Golang中github.com/gopherjs/gopherjs/js.Object.Invoke方法的典型用法代码示例。如果您正苦于以下问题:Golang Object.Invoke方法的具体用法?Golang Object.Invoke怎么用?Golang Object.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/gopherjs/gopherjs/js.Object的用法示例。


在下文中一共展示了Object.Invoke方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: LoadTrack

func (c *controllerWrapper) LoadTrack(ident string, gids []string, cb *js.Object) {
	go func() {
		err := c.controller.LoadTrack(ident, gids)
		if err != nil {
			cb.Invoke("Hello failed: " + err.Error())
		}
	}()
}
开发者ID:badfortrains,项目名称:spotcontrol,代码行数:8,代码来源:main.go

示例2: SendVolume

func (c *controllerWrapper) SendVolume(ident string, volume int, cb *js.Object) {
	go func() {
		err := c.controller.SendVolume(ident, volume)
		if err != nil {
			cb.Invoke("Hello failed: " + err.Error())
		}
	}()
}
开发者ID:badfortrains,项目名称:spotcontrol,代码行数:8,代码来源:main.go

示例3: SendHello

func (c *controllerWrapper) SendHello(cb *js.Object) {
	go func() {
		err := c.controller.SendHello()
		if err != nil {
			cb.Invoke("Hello failed: " + err.Error())
		}
	}()
}
开发者ID:badfortrains,项目名称:spotcontrol,代码行数:8,代码来源:main.go

示例4: loginSaved

func loginSaved(username, authData string, appkey string, cb *js.Object) {
	go func() {
		key, _ := base64.StdEncoding.DecodeString(appkey)
		data, _ := base64.StdEncoding.DecodeString(authData)
		conn, _ := MakeConn()
		sController, err := spotcontrol.LoginConnectionSaved(username, data, key, "spotcontrol", conn)
		if err != nil {
			cb.Invoke(nil, "", "login failed")
		}
		c := &controllerWrapper{controller: sController}
		cb.Invoke(js.MakeWrapper(c), authData, nil)
	}()
}
开发者ID:badfortrains,项目名称:spotcontrol,代码行数:13,代码来源:main.go

示例5: login

func login(username, password, appkey string, cb *js.Object) {
	go func() {
		key, _ := base64.StdEncoding.DecodeString(appkey)
		conn, _ := MakeConn()
		sController, err := spotcontrol.LoginConnection(username, password, key, "spotcontrol", conn)
		if err != nil {
			cb.Invoke(nil, "", "login failed")
		} else {
			authData := sController.SavedCredentials
			c := &controllerWrapper{controller: sController}
			cb.Invoke(js.MakeWrapper(c), base64.StdEncoding.EncodeToString(authData), nil)
		}
	}()
}
开发者ID:badfortrains,项目名称:spotcontrol,代码行数:14,代码来源:main.go

示例6: parsePSD

func parsePSD(in *js.Object, progress *js.Object, complete *js.Object, failed *js.Object) {
	go func() {
		defer func() {
			if err := recover(); err != nil {
				failed.Invoke(fmt.Sprint("uncaught exception occurred on during parsing PSD: ", err))
			}
		}()
		r, err := newReaderFromJSObject(in)
		if err != nil {
			failed.Invoke(err.Error())
			return
		}
		canvasMap := map[int][2]*js.Object{}
		root, err := parse(r, func(prog float64) {
			progress.Invoke(prog)
		}, func(seqID int, l *psd.Layer) {
			var canvas, mask *js.Object
			if l.HasImage() && !l.Rect.Empty() {
				var a []byte
				if ach, ok := l.Channel[-1]; ok {
					a = ach.Data
				}
				canvas = createImageCanvas(
					l.Rect.Dx(),
					l.Rect.Dy(),
					l.Channel[0].Data,
					l.Channel[1].Data,
					l.Channel[2].Data,
					a,
				)
			}
			if m, ok := l.Channel[-2]; ok && l.Mask.Enabled() && !l.Mask.Rect.Empty() {
				mask = createMaskCanvas(l.Mask.Rect.Dx(), l.Mask.Rect.Dy(), m.Data, l.Mask.DefaultColor)
			}
			canvasMap[seqID] = [2]*js.Object{canvas, mask}
		})
		if err != nil {
			failed.Invoke(err.Error())
			return
		}
		mapCanvasGo(canvasMap, root)
		complete.Invoke(root)
	}()
}
开发者ID:oov,项目名称:PSDTool,代码行数:44,代码来源:psd_js.go

示例7: parsePSDInWorker

func parsePSDInWorker(in *js.Object, progress *js.Object, complete *js.Object, failed *js.Object) {
	script := js.Global.Get("document").Call("getElementById", "psdgo")
	if !script.Bool() {
		panic("id=psdgo not found")
	}
	worker := js.Global.Get("Worker").New(script.Get("src"))
	script.Set("psdgo", worker)
	canvasMap := map[int][2]*js.Object{}
	worker.Set("onmessage", func(e *js.Object) {
		data := e.Get("data")
		switch data.Get("type").String() {
		case "makeCanvas":
			var canvas, mask *js.Object
			if w, h := data.Get("w").Int(), data.Get("h").Int(); w*h > 0 {
				r := js.Global.Get("Uint8Array").New(data.Get("r")).Interface().([]byte)
				g := js.Global.Get("Uint8Array").New(data.Get("g")).Interface().([]byte)
				b := js.Global.Get("Uint8Array").New(data.Get("b")).Interface().([]byte)
				var a []byte
				if aab := data.Get("a"); aab.Bool() {
					a = js.Global.Get("Uint8Array").New(aab).Interface().([]byte)
				}
				canvas = createImageCanvas(w, h, r, g, b, a)
			}
			if m := data.Get("m"); m.Bool() {
				mask = createMaskCanvas(
					data.Get("mw").Int(), data.Get("mh").Int(),
					js.Global.Get("Uint8Array").New(m).Interface().([]byte),
					data.Get("mc").Int(),
				)
			}
			canvasMap[data.Get("id").Int()] = [2]*js.Object{canvas, mask}
		case "progress":
			progress.Invoke(data.Get("progress"))
		case "error":
			failed.Invoke(data.Get("error"))
		case "complete":
			root := data.Get("root")
			mapCanvasJS(canvasMap, root)
			complete.Invoke(root)
		}
	})
	if jsbuiltin.InstanceOf(in, js.Global.Get("ArrayBuffer")) {
		worker.Call("postMessage", js.M{
			"input": in,
		}, js.S{in})
	} else {
		worker.Call("postMessage", js.M{"input": in})
	}
}
开发者ID:oov,项目名称:PSDTool,代码行数:49,代码来源:psd_js.go

示例8: jsCallback

func jsCallback(f *js.Object) Callback {
	if f == nil || f == js.Undefined {
		return nil
	}
	return func(val interface{}) interface{} { return f.Invoke(val) }
}
开发者ID:augustoroman,项目名称:promise,代码行数:6,代码来源:promisify.go


注:本文中的github.com/gopherjs/gopherjs/js.Object.Invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。