-
Notifications
You must be signed in to change notification settings - Fork 585
switch/select type dynamically #320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
switch/select type dynamically
I like the changes here but it decreases test coverage. Could you write some tests to cover the changes you made? Thanks! |
1) added setStorageType(type) 2) added type to relevant calls except removeFromLocalStorage(...), as it's a vararg variety, but easy to do if needed. This is a non-intrusive patch, as it preserves original functionality with minimal changes, but adds storage type selectability when needed. Typical use case: your existing code picked one type as default, but in a couple of places you need to use the other type, then try this: setStorageType(non-default-type); // switch to new type ...do your storage calls setStorageType(default-type); // restore default Or you can specify a type to each call directly (without type specified, will use whatever the last type active).
removeFromLocalStorage() supports selecting storage type as the last parameter. not as optimized as I'd like for the patches, but they're non-invasive, and easy to reason for correctness. This completes the type selection patch (TODO: need to add tests).
removeFromLocalStorage() to take type param
Thanks. |
This should be documented in the readme to let people know it is possible. |
Not sure this was the best implementation - why, when specified in the call directly |
This is a non-intrusive patch, as it preserves original functionality with minimal changes, but adds storage type selectability when needed.
Typical use case:
your existing code picked one type as default, but in a couple of places you need to use the other type, then try this:
setStorageType(non-default-type); // switch to new type
...do your storage calls
setStorageType(default-type); // restore default
Or you can specify a type to each call directly (without type specified, will use whatever the last type active).