Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

window.History() is not implemented. #41

Open
FlorianUekermann opened this issue Jul 17, 2017 · 4 comments
Open

window.History() is not implemented. #41

FlorianUekermann opened this issue Jul 17, 2017 · 4 comments

Comments

@FlorianUekermann
Copy link

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

@dmitshur
Copy link
Collaborator

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 dmitshur changed the title Can't obtain window.history window.History() is not implemented. Jul 17, 2017
@inliquid
Copy link
Contributor

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

@mihaiav
Copy link

mihaiav commented Nov 2, 2019

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
Copy link

mihaiav commented Nov 2, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants