go-js-dom icon indicating copy to clipboard operation
go-js-dom copied to clipboard

window.History() is not implemented.

Open FlorianUekermann opened this issue 8 years ago • 4 comments

window.History() returns nil There is a pull request, from half a year ago.

FlorianUekermann avatar Jul 17 '17 12:07 FlorianUekermann

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.

dmitshur avatar Jul 17 '17 17:07 dmitshur

@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.

inliquid avatar Jul 12 '19 00:07 inliquid

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?

mihaiav avatar Nov 02 '19 00:11 mihaiav

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)
}

mihaiav avatar Nov 02 '19 00:11 mihaiav