)
// Callback is a Go function that got wrapped for use as a JavaScript callback.
-// A Callback can be passed to functions of this package that accept interface{},
-// for example Value.Set and Value.Call.
type Callback struct {
Value // the JavaScript function that queues the callback for execution
id uint32
}
-// NewCallback returns a wrapped callback function. It can be passed to functions of this package
-// that accept interface{}, for example Value.Set and Value.Call.
+// NewCallback returns a wrapped callback function.
//
// Invoking the callback in JavaScript will queue the Go function fn for execution.
// This execution happens asynchronously on a special goroutine that handles all callbacks and preserves
func valueGet(v ref, p string) ref
-// Set sets the JavaScript property p of value v to x.
+// Set sets the JavaScript property p of value v to ValueOf(x).
func (v Value) Set(p string, x interface{}) {
valueSet(v.ref, p, ValueOf(x).ref)
}
func valueIndex(v ref, i int) ref
-// SetIndex sets the JavaScript index i of value v to x.
+// SetIndex sets the JavaScript index i of value v to ValueOf(x).
func (v Value) SetIndex(i int, x interface{}) {
valueSetIndex(v.ref, i, ValueOf(x).ref)
}
// Call does a JavaScript call to the method m of value v with the given arguments.
// It panics if v has no method m.
+// The arguments get mapped to JavaScript values according to the ValueOf function.
func (v Value) Call(m string, args ...interface{}) Value {
res, ok := valueCall(v.ref, m, makeArgs(args))
if !ok {
// Invoke does a JavaScript call of the value v with the given arguments.
// It panics if v is not a function.
+// The arguments get mapped to JavaScript values according to the ValueOf function.
func (v Value) Invoke(args ...interface{}) Value {
res, ok := valueInvoke(v.ref, makeArgs(args))
if !ok {
// New uses JavaScript's "new" operator with value v as constructor and the given arguments.
// It panics if v is not a function.
+// The arguments get mapped to JavaScript values according to the ValueOf function.
func (v Value) New(args ...interface{}) Value {
res, ok := valueNew(v.ref, makeArgs(args))
if !ok {
)
// TypedArrayOf returns a JavaScript typed array backed by the slice's underlying array.
-// It can be passed to functions of this package that accept interface{}, for example Value.Set and Value.Call.
//
// The supported types are []int8, []int16, []int32, []uint8, []uint16, []uint32, []float32 and []float64.
// Passing an unsupported value causes a panic.