go-js-dom
go-js-dom copied to clipboard
window.History() is not implemented.
window.History() returns nil There is a pull request, from half a year ago.
The pull request which attempts to fix this is #35.
I'll try to find time soon to look at it again.
The reason it wasn't merged long ago is because it's still unclear what type to use for representing state. The PR currently uses interface{}, but I want to confirm whether or not that's the best API to go with.
@dominikh any idea when will this be implemented? I'm using dom lib but have to revert to gopherjs/gopherjs/js in this particular case.
any update on this? in browser state is a javascript/json object defined by the user/client so I guess interface is the "right" go type. What else does Go use to define "any" type?
After a bit more consideration I believe this is a bit more complex and I don't really understand what value type history.Get returns or history.Set expects . Ideally we should marshal/unmarshal the state before to send it to make sure it's encoded per our specifications but I'm not sure if syscall/js is happy with our encoded json
e.g.
func (h *history) State(v interface{})error{
raw_json := h.Get("state")
return json.Unmarshal([]byte(raw_json), v)
}