nitedani / zustand-querystring

A Zustand middleware that syncs the store with the querystring.
54 stars 6 forks source link

feat: make the encoding/decoding logic separate from core #12

Open nitedani opened 2 months ago

nitedani commented 2 months ago

Feature idea: Make the encoding/decoding logic separate from core:

import create from "zustand";
import { querystring } from "zustand-querystring";
import urlon from "zustand-querystring/encoding/urlon";

import url from "zustand-querystring/encoding/url";
import base64 from "zustand-querystring/encoding/base64";

const useStore = create()(
  querystring(
    (set, get) => ({
      count: 0,
    }),
    {
    encoding: urlon
    // ...rest of options
    },
  ),
);