Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

@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.

Install

npm i @dot-event/store

DownloadsWeekly Downloads

11

Version

7.0.18

License

MIT

Unpacked Size

10.8 kB

Total Files

6

Last publish

Collaborators

  • avatar