Socket
Book a DemoInstallSign in
Socket

ngrx-rehydrate

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngrx-rehydrate

Persists parts of the state to localStorage and automatically load them as initial state after refresh/revisit of the page.

1.0.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

ngrx-rehydrate

Persists parts of the state to localStorage and automatically load them as initial state after refresh/revisit of the page.

Usage

export const exampleReducer = createRehydrateReducer(
    { key: 'key1' },
    INITIAL_STATE,
    on(setAction, (state, { flag }) => ({ ...state, flag })),
);
function createRehydrateReducer<S, A extends Action = Action, R extends ActionReducer<S, A> = ActionReducer<S, A>>(
    config: RehydrateRecucerConfig,
    initialState: S,
    ...ons: ReducerTypes<S, ActionCreator[]>[]
): R 

where

ParamDescription
configRehydrateRecucerConfig object for rehydration options
initialStatesame as with the default createReducer function
onssame as with the default createReducer function

Refs

For more usage examples see the tests https://github.com/amdor/ngrx-rehydrate/blob/main/test/create-rehydrate-reducer.spec.ts

More on rehydration: https://medium.com/betsson-group/the-easiest-way-to-keep-ngrx-state-after-refresh-rehydrate-it-from-localstorage-8cd23b547aac

Types

RehydrateRecucerConfig

PropertyDescription
keythe key to store the substate by. must be unique otherwise 2 state slices would try saving to the same localStorage key

Keywords

rehydration

FAQs

Package last updated on 07 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.