Skip to content
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

Can't blacklist a subset #21

Open
martakielpinska opened this issue Jun 22, 2018 · 2 comments
Open

Can't blacklist a subset #21

martakielpinska opened this issue Jun 22, 2018 · 2 comments

Comments

@martakielpinska
Copy link

martakielpinska commented Jun 22, 2018

Hello,
I'm running into troubles trying to blacklist a part of my reducer.
here is my entriesReducer's initial state:


const initialState = {
    serverCopy : [],
    entriesPerDay : [], 
    pickedDate : new Date(),
    total: "0:00",
    workingCopy : [],
    activities: [],
    pickedEntry: null,
    loggedInUser: null,
    newnewPickedDate : null,
}

I want the entriesPerDay, the pickedDate and the pickedEntry to have their default values when the app starts. That's the most important thing. If possible, I'd like to rehydrate ONLY the serverCopy and the workingCopy. Here is the code of my store configurations:


const saveSubsetFilter = createFilter(
    'entriesReducer',
    ['serverCopy', 'workingCopy']
  );

    const loadSubsetFilter = createFilter(
        'entriesReducer',
    null,
    ['serverCopy', 'workingCopy']
  );

   const saveSubsetBlacklistFilter = createBlacklistFilter(
    'entriesReducer',
    [ 'pickedEntry' , 'entriesPerDay', 'pickedDate']
  );

const persistConfig = {
    key: 'root',
    storage: storage,
    stateReconciler: autoMergeLevel2  ,// see "Merge Process" section for details.
    transforms: [
    
        saveSubsetFilter,
      loadSubsetFilter,
      saveSubsetBlacklistFilter
     
    ]
   };

When I reload the app everything in the entriesReducer gets rehydrated. Why would that happen?
help

@martakielpinska martakielpinska changed the title Can't blacklist a subset that holds a date Can't blacklist a subset Jun 22, 2018
@devpascoe
Copy link

devpascoe commented Sep 20, 2018

I had a similar issue just now. using the actual reducer object rather than a string seemed to do the trick. try passing entriesReducer instead of 'entriesReducer'

const saveSubsetBlacklistFilter = createBlacklistFilter(
entriesReducer,
[ 'pickedEntry' , 'entriesPerDay', 'pickedDate']
);

I also found that i needed to restart the app on iOS, a simple cmd+R reload didnt work.

... update....scratch that. getting inconsistent results.

another update. I'm having better luck just sticking to whitelists with createFilter and forgetting about blacklists. And gone back to using the string for the reducer rather than the object itself. Working well.

@ThomasStubbe
Copy link

ThomasStubbe commented Jun 27, 2019

Did you manage to solve this with blacklists? I'm having the same issue. The createBlacklistFilter simply doesn't work. The README.md also says to use persistStore to pass the filter, but that's an invalid property. I suppose it should be in the persistCombineReducers's config... ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants