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

Non-mutating URLSearchParams set? #105

Open
AlexMoutonNoble opened this issue Jul 26, 2022 · 2 comments
Open

Non-mutating URLSearchParams set? #105

AlexMoutonNoble opened this issue Jul 26, 2022 · 2 comments

Comments

@AlexMoutonNoble
Copy link

Hi All
Its given me some pain that this function doesnt return a URLSearchParams that can be passed back up the chain to location.
How about a PR for a set that returns t?

Thanks
Alex

@TheSpyder
Copy link
Owner

Can you please post some sample JavaScript that shows what you're trying to achieve? I think I know what you're asking for but I'd like to make sure.

We are going to break a lot of APIs with version 2, as we adopt the objects with optional fields feature of ReScript 10, so that might be an opportunity to simply add the t return to set directly.

@AlexMoutonNoble
Copy link
Author

Trying to assert a query parameter from Location i ended up with:

			let dict = Window.location()
			->Webapi.Dom.Location.search
			->Webapi.Url.URLSearchParams.make
			->Webapi.Url.URLSearchParams.entries
			->Js.Array.from
			->Js.Dict.fromArray

			dict->Js.Dict.set("output", query)

			dict
			->Webapi.Url.URLSearchParams.makeWithDict
			->Webapi.Url.URLSearchParams.toString
			->Webapi.Dom.Location.setSearch(Window.location(), _)

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

2 participants