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
In my use case, I'd like to have a model that is isomorphic and handlers against this model mutate the model. In a normal world, I'd have the model once in JavaScript with mutators written in JavaScript, then I'd have the model again in Go with Go-based mutators.
In a Protobuf/GopherJS world, I'd like to define my model in a proto, generate the appropriate code for the model, then ship an initalState from Go code to the JS-client as a protobuf-on-the-wire which is deserialized and kept as a JS model (used in this case as a React model). I'm quite happy with JSX and various JavaScript UI-isms, so I don't want to use Go for React completely.
When a change to the model is needed, I want the server to create an event that mutates the model, then send that event to the browser. The handler for that event on the JS client would make the same mutation (because it would a GopherJS compiled version of the Go code).
It's my understanding that to turn the Go object to a JS object, I would need to include a *js.Object and the fields would need to be tagged:
Name string `js:"name"`
..it seems the protoc in gopherjs mode doesn't do this; am I missing something? Am I expected to use pairs of Marshal methods in Go/JS to shovel the protobuf-serialized bytes between the languages? That feels like it'd be much slower, but I'm not really sure what heavy-lifting happens in GopherJS otherwise?
The text was updated successfully, but these errors were encountered:
Yeah, so the objects don't automatically include the *js.Object type because it's only relevant on the border between JS and GopherJS, whereas this project was designed with a pure-Go use case in mind. I'm not entirely sure I understand your use case, but I think you might just want to duplicate the relevant types? You might be able to create wrapper types that just compose the generated protobuf types?
In my use case, I'd like to have a model that is isomorphic and handlers against this model mutate the model. In a normal world, I'd have the model once in JavaScript with mutators written in JavaScript, then I'd have the model again in Go with Go-based mutators.
In a Protobuf/GopherJS world, I'd like to define my model in a proto, generate the appropriate code for the model, then ship an initalState from Go code to the JS-client as a protobuf-on-the-wire which is deserialized and kept as a JS model (used in this case as a React model). I'm quite happy with JSX and various JavaScript UI-isms, so I don't want to use Go for React completely.
When a change to the model is needed, I want the server to create an event that mutates the model, then send that event to the browser. The handler for that event on the JS client would make the same mutation (because it would a GopherJS compiled version of the Go code).
It's my understanding that to turn the Go object to a JS object, I would need to include a
*js.Object
and the fields would need to be tagged:..it seems the protoc in gopherjs mode doesn't do this; am I missing something? Am I expected to use pairs of Marshal methods in Go/JS to shovel the protobuf-serialized bytes between the languages? That feels like it'd be much slower, but I'm not really sure what heavy-lifting happens in GopherJS otherwise?
The text was updated successfully, but these errors were encountered: