bjoluc / next-redux-cookie-wrapper

Sync a subset of your Redux state with cookies in Next.js :cookie: :sparkles:
MIT License
114 stars 4 forks source link

Expose functions to manually parse cookies #40

Open bjoluc opened 2 years ago

bjoluc commented 2 years ago

@bjoluc I was thinking that it would be nice if we can expose decompressFromEncodedURIComponent so that we don't need to install lz-string on our project to decode the cookie data. Is this possible ?

Originally posted by @bryantobing12 in https://github.com/bjoluc/next-redux-cookie-wrapper/issues/17#issuecomment-1083942458

@bryantobing12 Thanks, agree! I'd like to have two functions, one for compressed and one for non-compressed cookies. I'd also include JSON.parse in the exposed methods, unless there's a reason not to do so?

bjoluc commented 2 years ago

Reconsidering this in the light of #41, it may be nice to make this config-aware, something like

function getSubtreeFromCookie(middlewareConfig: NextReduxCookieMiddlewareConfig, subtree: string, context?: ...)