obake.js

1.2.2 • Public • Published

Statement management with proxies and promise...in a dead simple way



Installation

npm install obake.js --save

Why make this?

  • I found objects in javascript and that have mutation listeners
  • they allow for valuation |・д・)ノ
  • promise based so no race conditions! ( ´ ▿ ` )

Examples

// the defaultState is the state you want to proxy

//store.ts
import { reducer } from 'obake.js';

export const defaultState = {
  greeting: 'Spooky Ghost (ノ⊙﹏⊙)ノ',
 }

export const reducers = {
  updateGreeting: reducer((state, value: string) => {
    state.greeting = value;
  }),
}

//actions.ts
import { state } from './store';

export function handleGreetingClick() {
  state._update('updateGreeting', "Calm Ghost ( ´ ▿ ` )")
};

as you can see however it takes an reducer name which must be registered in the reducers, this way you can't just mutate the object willy nilly.

there you go; you have reducers, you have a safe way to mutate it your store.

Optional function reducer to make your reducers easier to read and keep the return consistent but its optional

View Reducer Function

Demo

https://obake.glitch.me/

Package Sidebar

Install

npm i obake.js

Weekly Downloads

1

Version

1.2.2

License

ISC

Unpacked Size

48.4 kB

Total Files

8

Last publish

Collaborators

  • stagfoo