-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathelectron.go
More file actions
49 lines (43 loc) · 1.27 KB
/
electron.go
File metadata and controls
49 lines (43 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Package electron implements an API translator and some convenience functions for creating
// Electron APP using Gopherjs.
//
// Usage
//
// go get github.com/oskca/gopherjs-electron
// go generate # calling the API translator
//
// API Translator
//
// The translator reads electron api json file and output the corresponding gopherjs struct and
// functions into files with raw_ prefix.
//
// Easy binding functions
//
// Hand written binding functions/struct lives in ex_*.go files and have Ex postfix.
package electron
import (
"github.com/gopherjs/gopherjs/js"
)
var (
require = js.Global.Get("require")
electron = require.Invoke("electron")
remote = electron.Get("remote")
useRemote = false
)
//go:generate -command json2rawApi go run json2rawApi/main.go json2rawApi/types.go json2rawApi/templates.go
//go:generate json2rawApi -c -o . json2rawApi/electron-api-1.4.15.json
func GetApp() *AppModule {
return GetAppModule()
}
// Get returns a electron or `electron.remote` module
func Get(name string) *js.Object {
if useRemote {
return remote.Get(name)
}
return electron.Get(name)
}
// UseRemote switch `electron.Get` to get module through `electron.remote`
// this functon must be call when use electron.remote in render process
func UseRemote() {
useRemote = true
}