Coder Social home page Coder Social logo

debug go-app in nowasm about go-app HOT 4 CLOSED

gepengscu avatar gepengscu commented on September 22, 2024
debug go-app in nowasm

from go-app.

Comments (4)

oderwat avatar oderwat commented on September 22, 2024

I guess you mean it limits your development using Go-App?

Could you give an example what is problematic for you to get right? Are you trying to combine "normal" JavaScript libraries with Go-App?

We generally do not have problems with debugging and bug fixing for our steadily growing applications that are from using WASM / Go-App. Sure, a step debugger that links back to the Go source would be nice, but using our print logging with stack traces works very well for us and writing smaller example applications before using new functionalities in a larger project makes things also more manageable.

P.S.: If you need some private Methods, just check out the Go-App code and use a "go.work" file in the project. Then you can add all the debugging you need. This possibility is one of the reasons why we use Go in the company.

from go-app.

gepengscu avatar gepengscu commented on September 22, 2024

I use the following codes in unit test. The code is mostly effective in logical testing. I think that it will be nice if a go side DOM is supported in go-app nowasm mode.

package tester

import (
	"fmt"
	"github.com/maxence-charriere/go-app/v9/pkg/app"
)

func CValue(v any) Value {
	return value{
		Value:   app.ValueOf(v),
		value:   v,
		methods: make(map[any]func(args ...any) app.Value),
	}
}

type (
	Value interface {
		app.Value
		Methods(map[string]func(args ...any) app.Value) Value
	}

	value struct {
		app.Value
		value   any
		methods map[any]func(args ...any) app.Value
	}
)

func (v value) Methods(m map[string]func(args ...any) app.Value) Value {
	for k, f := range m {
		v.methods[k] = f
	}
	return v
}

func (v value) Call(m string, args ...any) app.Value {
	if f, ok := v.methods[m]; ok {
		return f(args...)
	}
	fmt.Println("unknown function ", m)
	return CValue(v.value)
}

func (v value) IsNull() bool {
	return v.value == nil
}

This is logic test.

func TestFundamentals(t *testing.T) {
	v := Fundamentals(0)
	canvas := tester.CValue(map[any]any{
		"width":  100,
		"height": 100,
	}).Methods(map[string]func(args ...any) app.Value{
		"getContext": func(args ...any) app.Value {
			//name := args[0].(string)
			//attrs := args[1]
			return tester.CValue(map[any]any{}).
				Methods(map[string]func(args ...any) app.Value{
					"getParameter": func(args ...any) app.Value {
						return tester.CValue(map[any]any{})
					},
					"getExtension": func(args ...any) app.Value {
						return tester.CValue(map[any]any{})
					},
					"createTexture": func(args ...any) app.Value {
						return tester.CValue(map[any]any{})
					},
					"bindTexture": func(args ...any) app.Value {
						return tester.CValue(map[any]any{})
					},
					"texParameteri": func(args ...any) app.Value {
						return tester.CValue(map[any]any{})
					},
				})
		},
		"addEventListener": func(args ...any) app.Value {
			return tester.CValue(map[any]any{})
		},
		"removeEventListener": func(args ...any) app.Value {
			return tester.CValue(map[any]any{})
		},
	})
	v.Run(canvas)
}

from go-app.

oderwat avatar oderwat commented on September 22, 2024

What is 'go-app nowasm mode'? Do you mean using the Go-App declarative HTML generation? Isn't this a totally bloated way to create a standard HTML web server?

from go-app.

gepengscu avatar gepengscu commented on September 22, 2024

Go.work is a good idea.Thank you @oderwat very much.

from go-app.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.