New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@lauf/store-edit

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lauf/store-edit

Intuitive editing of @lauf/store state, (using Immer drafts)

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

Edit a store's immutable state

An idiot-proof mechanism to write @lauf/store state without breaking immutability. Guarantees safe Immutable edits without needing to learn Immutable update patterns

Read the API Reference or the reference usages below.

Usage

Making Edits

// given this example store
const counterState = createStore({ counter: 0 });

// editing a draft writes a new immutable state
edit(counterState, (draft) => (draft.counter += 1));

How it works

Your editor function is passed a draft object matching store state. Edit the draft using any javascript syntax. Immer then efficiently composes a new Immutable state to reflect your drafted changes, leaving the old state intact. The new state is passed to store.write(...).

Import OR Require

import { edit } from "@lauf/store-edit"; // for esm
const { edit } = require("@lauf/store-edit"); // for commonjs

Getting Started

Install

npm install @lauf/store-edit

Demonstration Apps

Selected Example Counter Apps offer minimal demonstrations of @lauf/store-edit. See the following...

FAQs

Package last updated on 30 Apr 2023

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