react-easy-params icon indicating copy to clipboard operation
react-easy-params copied to clipboard

Allow disabling of certain features

Open lostpebble opened this issue 7 years ago • 2 comments

This kind of a continuation of the last one. Sorry for another issue 😅

So as mentioned in the last issue, I wasn't actually using the params side of this library - just the storage.

Would it be possible to provide an option to disable the params side of things? As right now, I'm getting behaviour like this (the params are auto-converting to types as clarified in the last issue):

something?event= -> something?event=""

But in my current use-case, because I'm not actually using the params side of the library and the types it provides using the " (quotations), my event input is being filled with the empty "" (double quotations).

I think there should be a way to disable / enable parts of the library, or each feature should perhaps be available through its own library... so maybe an extra one called react-easy-storage? In my current use-case I'd be able to use that one and cut out the params side of things for now.


EDIT:

In actual fact, I kinda like what you're doing here:

key = encodeURIComponent(key)
value = encodeURIComponent(JSON.stringify(value))

and here:

const key = decodeURIComponent(keyValue[0])
const value = decodeURIComponent(keyValue[1])
try {
    params[key] = JSON.parse(value)
} catch (err) {
    params[key] = value
}

I guess that takes care of converting everything correctly and maintaining type information? I may just implement this in my current use-case as well, as I agree its quite nice to have that information. Then my code should be compatible - so its no biggy.

But perhaps still something to look into for people who do want to only opt in to a certain part of the library.

lostpebble avatar Jun 14 '18 17:06 lostpebble

Hi!

I think there is a pretty simple solution. The first url -> params -> url sync should leave the url in place, it should only start modifying the url when you start to explicitly use and mutate the params object. (I can add this, if you like the idea too).

Sorry for the late response, I was busy with a few other things.

solkimicreb avatar Jun 17 '18 07:06 solkimicreb

Okay great. I think starting the process of working with the url and the params should begin once the user starts interaction with that part of the library (means they are basically opting in to that functionality).

No worries about late responses, schedules get busy 🙂

lostpebble avatar Jun 18 '18 09:06 lostpebble