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

dyad

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dyad

A `(state, action) => state` key-value event emitting store for TypeScript and JavaScript apps

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

Dyad

Store app state as key-value pairs.

Update state using a reactive (state, action) => state pattern.

Listen for changes to a key; get notified if-and-only-if it changes (never when another key changes).

Installation

npm install dyad

Usage

const Dyad = require('dyad')
const store = Dyad.getInstance()

// Set initial `counter` state.
store.initialize({counter: 0})

// Register listener for changes to `counter`.
store.on('counter', (nextValue) => {
  console.log(nextValue)
})

// Register reducers.
store.bind({
  DECREMENT: (_, set, action) => set('counter', (prevValue) => --prevValue),
  INCREMENT: (_, set, action) => set('counter', (prevValue) => ++prevValue)
})

// Dispatch actions.
store.dispatch({type: 'INCREMENT'})
store.dispatch({type: 'INCREMENT'})
store.dispatch({type: 'INCREMENT'})
store.dispatch({type: 'DECREMENT'})
store.dispatch({type: 'DECREMENT'})

// Logs `1` exactly once.

Keywords

async

FAQs

Package last updated on 02 Jun 2019

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