Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

minimalist-store

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

minimalist-store

a minimalist store using as maximum as possible of native object features + Proxy

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

a minimalist store using as maximum as possible of native object features + Proxy

Usage Example

import createModel from 'minimalist-store';

const store = {
  name: 'Diel',
  age: 10,
  get doubleAge() {
    return this.age * 2;
  }
};

const model = createModel(store);

// randomly generating a new `age` value each 400ms, just to test
setInterval(() => {
  model.set = { age: Math.random() };
}, 400);

// add a subscribe by fields that you wanna do something when updated
// subscribe can be used multiple times, 
// passing a list of fields to watch
model.subscribe(['age'], () => {
  console.log('new change >>>', model.doubleAge);
});

FAQs

Package last updated on 24 Feb 2020

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