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

How to exclude subkeys from ngrx-localstorage by angular service? #245

Open
mkvashennikov opened this issue Mar 7, 2023 · 0 comments
Open
Labels

Comments

@mkvashennikov
Copy link

mkvashennikov commented Mar 7, 2023

Me need to exclude user subkeys by currrent user platform in localStorageSyncReducer function.
How can i make this? (Me need to import external function from Angular service inside below function):

function localStorageSyncReducer(reducer: ActionReducer<any>): ActionReducer<any> {
  const rootKeys = Object.keys(initialAppState);
  const excludeUserFields = ['data', 'permissions'];
  if (environment.USE_SAFE_TOKEN) {
    excludeUserFields.push('token');
  }
  const keys = rootKeys.map((rootKey) => {
    const subKeys
      = rootKey === 'user'
        ? Object.keys(initialAppState[rootKey]).filter(
            (key) => excludeUserFields.indexOf(key) === -1,
          )
        : Object.keys(initialAppState[rootKey]);
    return { [rootKey]: subKeys };
  });

  return localStorageSync({ keys, rehydrate: true })(reducer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants