You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Im sure Im missing something but after reading the docs I am still a little confused about how to properly be able to access the runtime methods. Lets use this example to illustrate and Im hoping someone can educate me on what I am doing wrong.
I do what they say which is create a new instance of the struct (empty) and then set the context on it accordingly. Id like to be able to unmarshall some json into the struct that looks something like this:
type DeviceData struct { Data interface{} ctx context.Context }
and then be able to log it to the console for example with something like this:
func (d *DeviceData) PrintData() { runtime.LogPrintf(c.ctx, "%v\n", c.Data) }
However, when I do this I see an error that says
cannot call 'github.com/wailsapp/wails/v2/pkg/runtime.LogPrintf': An invalid context was passed. This method requires the specific context given in the lifecycle hooks:
Im guessing this is because the instance that I am unmarshalling into is different than the new one created in wails main.go file.
So, Im sure this is a newbie mistake but if I have a defined package, a struct and methods defined. How do I properly access the context so that I can call something like the method outlined below and it has the needed context.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Im sure Im missing something but after reading the docs I am still a little confused about how to properly be able to access the runtime methods. Lets use this example to illustrate and Im hoping someone can educate me on what I am doing wrong.
Looking at the docs here:
https://wails.io/docs/guides/application-development
I do what they say which is create a new instance of the struct (empty) and then set the context on it accordingly. Id like to be able to unmarshall some json into the struct that looks something like this:
type DeviceData struct { Data interface{} ctx context.Context }
and then be able to log it to the console for example with something like this:
func (d *DeviceData) PrintData() { runtime.LogPrintf(c.ctx, "%v\n", c.Data) }
However, when I do this I see an error that says
cannot call 'github.com/wailsapp/wails/v2/pkg/runtime.LogPrintf': An invalid context was passed. This method requires the specific context given in the lifecycle hooks:
Im guessing this is because the instance that I am unmarshalling into is different than the new one created in wails main.go file.
So, Im sure this is a newbie mistake but if I have a defined package, a struct and methods defined. How do I properly access the context so that I can call something like the method outlined below and it has the needed context.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions