4 ms·
This is a useful idea when you've got complex nested state. The problem is changing any particular part of the state is non-trivial. I ended up making `friendly
by jcuenod 4y ago
This is a useful idea when you've got complex nested state. The problem is changing any particular part of the state is non-trivial. I ended up making `friendly-serializer`[0] to "make objects more accessible in urls."
The idea is that instead of a base64 string, you get something that is much easier to edit in the url bar:
> name=John%20Doe&age=42&address.street=123%20Main%20Street&address.city=Anytown&address.state=CA&address.phoneNumbers.0=123-456-7890&address.phoneNumbers.1=234-567-8901
There's a similar npm project to [0] that I discovered after I'd published this, but I don't recall the name. PRs welcome.
[0] https://www.npmjs.com/package/friendly-serializer https://www.npmjs.com/package/friendly-serializer
- frosted-flakes 4y agoYou can have multiple values under the same search parameter. For example, ?a=b&a=c&a=d, which would be the array [b, c, d]. Including the index key seems redundant. The native URLSearchParams browser interface even supports this with the getAll method. https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/getAll https://developer.mozilla.org/en-US/docs/Web/API/URLSearchPa...
- jcuenod 4y agoGreat point! Added to my TODOs
- jcuenod 4y agoI found the other package: https://www.npmjs.com/package/friendly-querystring https://www.npmjs.com/package/friendly-querystring (noting mostly for my own sake)