INNER CODE UNIT · JavaScript

createMigrationFunction

zulip/zulip-mobile · src/redux-persist-migrate/index.js:43

export function createMigrationFunction(
  manifest: {| [string]: (PartialState) => PartialState |},
  reducerKey: string,
): PartialState => PartialState {
  const versionSelector = state => state && state[reducerKey] && state[reducerKey].version;
  const versionSetter = (state, version) => {
    if (['undefined', 'object'].indexOf(typeof state[reducerKey]) === -1) {
      logging.error(
        'redux-persist-migrate: state for versionSetter key must be an object or undefined',
        { version, reducerKey, 'actual-state': state[reducerKey] },
      );
      return state;
    }
    return { ...state, [reducerKey]: { ...state[reducerKey], version } };
  };

  const versionKeys = Object.keys(manifest)
    .map(processKey)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…