svelte-ux icon indicating copy to clipboard operation
svelte-ux copied to clipboard

Add queryParamsStore

Open techniq opened this issue 3 years ago • 1 comments

  • [x] Support simple types (numbers, strings, booleans)
  • [x] Support objects
  • [x] Support arrays
    • Return array even if single item
    • Arrays of simple types
    • Arrays of objects
  • [x] Handle datatype changing when only a single vs multiple selected (ex. select with a single vs multiple values)
  • [ ] Provide better errors when config not found (at least include param name)
  • [ ] Support updating single param with queryParamsStore
    • Either support property and only update those with keys passed (require null / undefined to remove) or expose function from store to set
  • [ ] Support specifying pushState (browser back) vs replaceState
  • [ ] Attempt to guess paramType based on default value and/or current params set?
    • Might be confusing when breaks in certain conditions
  • [ ] Consider supporting Number and [Number] along with 'number' and 'number[]' (etc)?
    • Support both formats?
    • What about json (JSON), object (Object)?
    • What about date vs datetime?
      • Maybe Date is bound to datetime and date is handled by passing in an implementation object with encode/decode (see below)
    • Support a custom format in the future (UTC date vs local date, etc)
      • Maybe passing in an implementation object with encode/decode (see below)
  • [ ] Consider supporting explicit object with {encode: ..., decode: ....}?
  • [ ] Differentiate between null and undefined
    • Should only undefined delete the value (null is persisted)? Example: active/inactive/all toggles

Useful links

  • https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
  • Svelte
    • https://stackoverflow.com/questions/57181704/svelte-components-store-load-state-into-from-url-hash-parameters
  • React
  • Libraries
    • https://github.com/sindresorhus/query-string (6.3k)
    • https://github.com/ljharb/qs (10.2k - 27.9k)
    • https://github.com/lukeed/qss (757b)

techniq avatar Feb 10 '22 13:02 techniq