Support window as second parameter

This commit is contained in:
Lea Anthony
2024-04-27 14:29:48 +10:00
parent c76b88b7b2
commit 8ea58bef2c
4 changed files with 30 additions and 13 deletions
+6 -6
View File
@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"reflect"
)
const (
@@ -105,12 +106,11 @@ func (m *MessageProcessor) processCallMethod(method int, rw http.ResponseWriter,
m.l.Unlock()
}()
// Check if the first bound method parameter is a Window interface
if len(boundMethod.Inputs) > 0 {
if boundMethod.Inputs[0].ReflectType.String() == "application.Window" {
// Prepend the options.Args with the current window
options.Args = append([]interface{}{window}, options.Args...)
}
// Check if the first or second bound method parameter is a Window interface
if len(boundMethod.Inputs) > 1 && (boundMethod.Inputs[0].ReflectType == reflect.TypeFor[Window]() ||
boundMethod.Inputs[1].ReflectType == reflect.TypeFor[Window]()) {
// Prepend the options.Args with the current window
options.Args = append([]interface{}{window}, options.Args...)
}
result, err := boundMethod.Call(ctx, options.Args)
if err != nil {