Socket
Socket
Sign inDemoInstall

mutable

Package Overview
Dependencies
5
Maintainers
3
Versions
427
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

mutable

Mutable state containers with dirty checking and more


Version published
Maintainers
3
Weekly downloads
21
increased by10.53%
Bundle size
54.2 kB
Minified + gzipped

Weekly downloads

Readme

Source

Mutable

npm version

Mutable state containers in javascript with dirty checking and more (WIP)

What Mutable does

Mutable is a mobx-compatible class system library. Mutable offers a unique runtime schema engine that enforces unidirectional data flow, and formalizes the structure of props and state. Mutable also supports data defaults, and non-nullable types.

Using mutable

Add Mutable to your project by installing it with npm:

npm install mutable --save

Simple code example:

import * as mutable from 'mutable';
import * as mobx from 'mutable';

// define a mutable class by providing a name and a spec (class schema)
const Dude = mutable.define('Dude', {
    spec: ()=>({
        name: Mutable.String.withDefault('Leon'),
        age: Mutable.Number.withDefault(110),
        address: Mutable.String.withDefault('no address')
    })
});
 
// Mutable types accept custom data according to their spec as the first argument of their constructor
const dude = new Dude({name:'Ido'});

mobx.autorun(function () {
    console.log(dude.name + ' ' + dude.age);
});
// prints: Leon 110
dude.name = 'Mike';
// prints: Mike 110

Integrating mutable into React components is up to the user.

how to build and test locally from source

Clone this project locally. Then, at the root folder of the project, run:

npm install
npm test

how to run local continous test feedback

At the root folder of the project, run:

npm start

Then, open your browser at http://localhost:8080/webtest.bundle and see any changes you make in tests or code reflected in the browser

Versioning

Currently Mutable is in alpha mode. As such, it does not respect semver.

License

We use a custom license, see LICENSE.md

Similar Projects

These are examples of the kinds of libraries we would like to model ourselves after.

  • NestedTypes : High-performance model framework, which can be used as drop-in backbonejs replacement.
  • mobx : Simple, scalable state management
  • alt : A library that facilitates the managing of state within your JavaScript applications. It is modeled after flux.
  • immutable.js : Immutable persistent data collections for Javascript which increase efficiency and simplicity
  • cls.js : Easy, dynamic (kind of mixin) javascript classes
  • observable-value: Object representation of mutable value

Keywords

FAQs

Last updated on 06 Jul 2017

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc