1.0.1 • Published 3 years ago

@creatorum/state v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Creatorum state utils package

Install

yarn add @creatorum/state

Short docs

StateField

Using in browser

<script src="//unpkg.com/@creatorum/state/dist/browser.js"></script>
// create field
var counter = Creatorum.state.createStateField(0);

// add reaction on field change
counter.watch(function(current, next) {
  console.log(current, prev);
});

// update counter
counter.set(1);
counter.set(2);
counter.set(3);

Using with webpack

import { createStateField } from '@creatorum/state';

// create field
const counter = createStateField(0);

// add reaction on field change
counter.watch((current, prev) => {
  console.log(current, prev);
});

// update counter
counter.set(1);
counter.set(2);
counter.set(3);