@dot-event/store

7.0.18 • Public • Published

@dot-event/store

dot-event immutable store

that's us

Install

npm install dot-event @dot-event/store

Setup

const dot = require("dot-event")()
require("@dot-event/store")(dot)

Usage

dot.set("prop", "prop2", "some value")
dot.get("prop", "prop2") // "some value"
dot.merge("prop", { prop3: "another value" })
dot.get("prop") // { prop2: "some value", prop3: "another value" }
dot.delete("prop")
dot.get() // {}

Listen to store changes

Use dot.on or dot.any on the store event id:

dot.on("store", "prop", () => {})

Queued update

Pass a function to dot.set for atomic operations:

dot.set("counter", value => (value || 0) + 1)

Raw state

The raw state object is available at dot.state.store.

Credit

Some of the immutability features were borrowed from debitoor/dot-prop-immutable.

Dependencies (0)

    Dev Dependencies (8)

    Package Sidebar

    Install

    npm i @dot-event/store

    Weekly Downloads

    1

    Version

    7.0.18

    License

    MIT

    Unpacked Size

    10.8 kB

    Total Files

    6

    Last publish

    Collaborators

    • winton