dominikh / go-js-dom

MIT License
252 stars 42 forks source link

Implementing window.history #35

Open itsmontoya opened 7 years ago

itsmontoya commented 7 years ago

Resolves #41.

dominikh commented 7 years ago

The issue is that data put into the history will be serialized by the browser. In turn, when you get it back out, you won't get an object of the Go type you put in. That makes the API rather awkward to use.

itsmontoya commented 7 years ago

@dominikh I understand there might be an issue here with the state field. I know currently, this value is not required by the browser. AFAIK it's used as an optional object. Instead of an interface{}, do you think it might be better suited to utilize a map[string]string or even a map[string]interface{}?

itsmontoya commented 7 years ago

@shurcooL - I made some changes based on your request. Please let me know if I missed anything

itsmontoya commented 7 years ago

Sorry to follow up @dominikh - just wanted to see if you had any suggestions. I want you to be satisfied with the implementation. At the same time, I really need window.History on my current project. :D

dmitshur commented 7 years ago

The issue is that data put into the history will be serialized by the browser. In turn, when you get it back out, you won't get an object of the Go type you put in. That makes the API rather awkward to use.

Would it make sense to use *js.Object type for state? I know it's not pretty, but at least you'd get back what you put in, right?

dominikh commented 7 years ago

I'm deferring this PR, and all decisions, to @shurcooL.

itsmontoya commented 7 years ago

@shurcooL - Reported issue was fixed, I also made an additional fix of similar nature to "back"

dmitshur commented 7 years ago

Following up here. @itsmontoya, have you seen my question in https://github.com/dominikh/go-js-dom/pull/35#issuecomment-268923431?