Documentation ¶
Index ¶
- Variables
- func Await(awaitable js.Value) ([]js.Value, []js.Value)
- func BindFunc(jsFuncName string, fn interface{}) error
- func BindFuncs(fnList map[string]interface{}) error
- func Close()
- func NewJsError(message string) map[string]string
- type AsyncInvoker
- type InputBinder
- type InputBuilder
- type OutputBinder
- type OutputBuilder
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMismatchedInputLength the length of input are mismatched ErrMismatchedInputLength = errors.New("binder: mismatched input length") // ErrMismatchedOutputLength the length of output are mismatched ErrMismatchedOutputLength = errors.New("binder: mismatched output length") // ErrBinderNotImplemented the type binder is not implemented yet ErrBinderNotImplemented = errors.New("binder: not impelmented") // ErrFuncNotSupported the type function is not supported yet ErrFuncNotSupported = errors.New("func: not supported") // ErrIsNotFunc bind works with func only ErrIsNotFunc = errors.New("func: bind works with func only") )
Functions ¶
func Await ¶
This function try to execute wasm functions that are wrapped with "Promise" see: https://stackoverflow.com/questions/68426700/how-to-wait-a-js-async-function-from-golang-wasm/68427221#comment120939975_68427221
func BindFunc ¶
BindFunc bind go func to js func in global only support - func(...) - func(...) error - func(...) T - func(...) (T,error)
func NewJsError ¶
Types ¶
type AsyncInvoker ¶
type InputBinder ¶
InputBinder convert inputs from js.Value to reflect.Value
type InputBuilder ¶
type InputBuilder struct { IsVariadic bool // contains filtered or unexported fields }
InputBuilder binder builder
func NewInputBuilder ¶
func NewInputBuilder(fn reflect.Type) *InputBuilder
NewInputBuilder create InputBuilder
func (*InputBuilder) Build ¶
func (b *InputBuilder) Build() (InputBinder, error)
Build build InputBinder js.ValueOf returns x as a JavaScript value:
| Go | JavaScript | | ---------------------- | ---------------------- | | js.Value | [its value] | | js.Func | function | | nil | null | | bool | boolean | | integers and floats | number | | string | string | | []interface{} | new array | | map[string]interface{} | new object |
Panics if x is not one of the expected types.
type OutputBinder ¶
OutputBinder convert Outputs from js.Value to reflect.Value
type OutputBuilder ¶
type OutputBuilder struct {
// contains filtered or unexported fields
}
OutputBuilder binder builder
func NewOutputBuilder ¶
func NewOutputBuilder(fn reflect.Type) *OutputBuilder
NewOutputBuilder create OutputBuilder
func (*OutputBuilder) Bind ¶
func (b *OutputBuilder) Bind(args []reflect.Value) []js.Value
Bind bind js Outputs to reflect values
func (*OutputBuilder) Build ¶
func (b *OutputBuilder) Build() (OutputBinder, error)
Build build OutputBinder js.ValueOf returns x as a JavaScript value:
| Go | JavaScript | | ---------------------- | ---------------------- | | js.Value | [its value] | | js.Func | function | | nil | null | | bool | boolean | | integers and floats | number | | string | string | | []interface{} | new array | | map[string]interface{} | new object |
Panics if x is not one of the expected types.