functions to set `window.location.href`
Closed this issue ยท 9 comments
It looks like there are functions in DOM.HTML.Location to read the current location, but there are no functions to set a location.
Were setting-functions left out for some reason? Would a pull request adding them be accepted?
They were left out due to laziness, this library is being lazily implemented ๐
I'd definitely accept a PR for setting them ๐
I'd probably prefer to just provide the functions like replace and assign for changing the URL though (https://www.w3.org/TR/html5/browsers.html#the-location-interface), unless you think there's a particularly good reason to provide a more setter-y kind of thing?
So you're imagining functions like these?
assign :: forall eff. Location -> String -> Eff (dom :: DOM | eff) Unit
replace :: forall eff. Location -> String -> Eff (dom :: DOM | eff) Unit
reload :: forall eff. Location -> Eff (dom :: DOM | eff) UnitYep, looks good to me! It's handy you're looking at this actually, I'm about to have the need to use it myself. ๐
Actually, maybe Location should always be the last argument? I'm can't remember how the argument order works elsewhere in this library...
Right, yes, looks like elsewhere we do things in that order, so Location after the url argument please for assign and replace.
@cdepillabout Is a patch for this immanent? Otherwise, I'm happy to take on the issue (I need it for my work today). [By the way, I need a setter for the hash property in particular; so I think it may make sense to provide bindings to the full interface of the Location object, including the setters to the properties.]
I guess we can close this ticket now.
Ah, I assumed it would close automatically as I saw you mention the issue number. You didn't use the magic words though ๐
@jonsterling Thanks! I was just about to start working on this. Looks like you beat me by a couple hours :-)