Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Add DOM.HTML.History.#75

Merged
garyb merged 5 commits into
purescript-deprecated:masterfrom
chexxor:add-history
Feb 14, 2017
Merged

Add DOM.HTML.History.#75
garyb merged 5 commits into
purescript-deprecated:masterfrom
chexxor:add-history

Conversation

@chexxor

@chexxor chexxor commented Jan 19, 2017

Copy link
Copy Markdown
Contributor

The type signature of state might be wrong: state :: forall a e. History -> Eff (history :: HISTORY | e) a. I'm not using it, but after some brief exploring of that property I believe it could be any shape, so I put a. The browser puts one type of data in there, but users could put any type there via pushState, per the history spec.

Fixes #74

@garyb

garyb commented Jan 19, 2017

Copy link
Copy Markdown
Member

I think Foreign would be a better choice than leaving state polymorphic in its return value then perhaps?

@chexxor

chexxor commented Jan 19, 2017

Copy link
Copy Markdown
Contributor Author

Oh good idea. I'll do the same for pushState.

@garyb

garyb commented Jan 19, 2017

Copy link
Copy Markdown
Member

Can you make Travis happy? It's just lint/style stuff, the fixes can probably be applied automatically.

@chexxor

chexxor commented Jan 21, 2017

Copy link
Copy Markdown
Contributor Author

Thanks @garyb. I don't know how I missed those warnings. I probably did pulp build instead of npm run build. Pushed a commit to fix.

@garyb garyb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, I noticed a few other things. This'll be the end of the requests, honest!

Comment thread src/DOM/HTML/History.purs
foreign import go :: forall e. History -> Delta -> Eff (history :: HISTORY | e) Unit
foreign import pushState :: forall e. History -> Foreign -> DocumentTitle -> URL -> Eff (history :: HISTORY | e) Unit
foreign import replaceState :: forall e. History -> Foreign -> DocumentTitle -> URL -> Eff (history :: HISTORY | e) Unit
foreign import state :: forall e. History -> Eff (history :: HISTORY | e) Foreign

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry I didn't notice this earlier, but can we put the History argument at the end for all of these? That's more consistent with the rest of the API, and is done so you can write things like:

go -2 =<< history =<< window

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I followed the pattern in Location module, but I see those functions only have one arg, but I look closer and see you're right. I'll update.

Comment thread src/DOM/HTML/History.purs Outdated
-- DocumentTitle will set value of `document.title`
newtype DocumentTitle = DocumentTitle String
newtype Delta = Delta Int
newtype URL = URL String -- Unsure how to better type this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you derive Eq, Ord, and Newtype instances for these please?

I know what you mean about URL, but I think it's fine as a newtype here, as the API we're providing with this library is supposed to be dumb anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Adding.

Comment thread src/DOM/HTML/History.js Outdated
@@ -0,0 +1,47 @@
// module DOM.HTML.History

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can drop these comments now, the compiler switched to using paths to figure out associated FFI files a few versions ago.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah neat, I didn't know that - I thought it was purely convention.

@chexxor

chexxor commented Jan 24, 2017

Copy link
Copy Markdown
Contributor Author

Awesome suggestions. I've updated and pushed a new commit.

@garyb garyb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Everything looks great now apart from one thing... need to update the FFI implementations to move history to the last argument too! 😄

@chexxor

chexxor commented Jan 25, 2017

Copy link
Copy Markdown
Contributor Author

Ah, yeah, good catch. I am using this branch in my project but I didn't update to this latest commit yet. I should do that to provide some assurance it's working as it should. I'll post here after I've done that. It'll be 1-3 days, I guess.

@garyb

garyb commented Feb 14, 2017

Copy link
Copy Markdown
Member

Thanks!

@garyb garyb merged commit bfa8bf2 into purescript-deprecated:master Feb 14, 2017
@chexxor chexxor deleted the add-history branch February 14, 2017 19:24
@chexxor

chexxor commented Feb 14, 2017

Copy link
Copy Markdown
Contributor Author

I haven't finished testing this in my app, but that's fine b/c I can just make another MR if I need to fix something. Thanks @garyb for reviewing!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants