Skip to content

Implementing window.history #35

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

itsmontoya
Copy link

@itsmontoya itsmontoya commented Dec 16, 2016

Resolves #41.

Copy link
Collaborator

@dmitshur dmitshur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very reasonable to me. I left 1 style suggestion, but I don't have any other comments.

Only thing... I think I remember discussing this with @dominikh and the tricky part was figuring out what type to use for state. Using interface{} seems okay, but maybe @dominikh had something elaborate in mind? If not, I think it's a fine starting point, isn't it?

dom.go Outdated
}

func (h *history) Back() {
h.Object.Call("forward")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style suggestion. For consistency with above h.Get and the rest of the package, you can skip skip .Object since it's an embedded struct, just do h.Call("forward").

Here, and in 4 places below.

@dominikh
Copy link
Owner

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

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

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

@itsmontoya
Copy link
Author

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

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?

dom.go Outdated
}

func (h *history) Length() int {
return h.Get("state").Int()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to write h.Get("length").Int() here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good catch. I'll fix

@dominikh
Copy link
Owner

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

@itsmontoya
Copy link
Author

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

@dmitshur
Copy link
Collaborator

Following up here. @itsmontoya, have you seen my question in #35 (comment)?

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

Successfully merging this pull request may close these issues.

3 participants