You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
455 B

  1. import { Iterable, fromJS } from 'immutable';
  2. export const STORE_HYDRATE = 'STORE_HYDRATE';
  3. export const STORE_HYDRATE_LAZY = 'STORE_HYDRATE_LAZY';
  4. const convertState = rawState =>
  5. fromJS(rawState, (k, v) =>
  6. Iterable.isIndexed(v) ? v.toList() : v.toMap().mapKeys(x =>
  7. Number.isNaN(x * 1) ? x : x * 1));
  8. export function hydrateStore(rawState) {
  9. const state = convertState(rawState);
  10. return {
  11. type: STORE_HYDRATE,
  12. state,
  13. };
  14. };