-
Notifications
You must be signed in to change notification settings - Fork 866
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
inbound and outbound wrong way round #188
Conversation
I spent an hour debugging my code before I realised this was the issue.
Thanks a lot for your PR! Are you sure if this is not an error in your client code? The documentation is consistent with our code: function createTransform (inbound, outbound, config = {}) {
let whitelist = config.whitelist || null
let blacklist = config.blacklist || null
function whitelistBlacklistCheck (key) {
if (whitelist && whitelist.indexOf(key) === -1) return true
if (blacklist && blacklist.indexOf(key) !== -1) return true
return false
}
return {
in: (state, key) => !whitelistBlacklistCheck(key) && inbound ? inbound(state, key) : state,
out: (state, key) => !whitelistBlacklistCheck(key) && outbound ? outbound(state, key) : state
}
}
export default createTransform taken from https://github.com/rt2zz/redux-persist/blob/master/src/createTransform.js#L11 |
I just checked the code:
Should this be transformer.in? It seems to make sense to me that rehydrating the store is 'in' and persisting it is 'out'. I guess this is just my misunderstanding the sense of inbound and outbound, where you have used 'in' to mean into persistent storage as opposed to into the redux store. Maybe this could be renamed then, such as 'toReduxStore' and 'toPersistentStorage', in and out are a bit vague and I assumed the opposite of what they are actually being used to mean |
@saberking Thanks for your explanation. I see where the confusion comes from. I think just flipping the names would not suffice, because there are likely others who'd expected it the way it is. Perhaps we can find a more meaningful name that signals where the data is flowing to. I like both |
I agree the naming is ambiguous. From redux-persist's perspective I think of it as owning the state in storage, whereas redux owns the application state, hence the in/out mapping you currently see. I agree with @marvinhagemeister rather than flipping it and making it confusing for the other half of users, lets make the terms explicit: |
After thinking about it the only thing that I'm afraid of is the resulting API breakage. We just passed 1000 stars here on github and there is probably a lot if code out there which relies on the current behaviour. We could leave the current methods intact and print a deprecation warning whenever they are called. |
Another option would be simply to make it explicit in the readme |
If I am not mistaken this PR is just to update readme. Side note. 1000 stars! thanks @marvinhagemeister, we made it ;) |
Should I close this? From our discussion the change to the readme should certainly not be the one I have proposed in this PR |
Just updated readme with explanatory comments 👍 |
I spent an hour debugging my code before I realised this was the issue.