UNPKG

826 BMarkdownView Raw
1# IndustryState [![Build Status](https://travis-ci.org/invrs/industry-state.svg?branch=master)](https://travis-ci.org/invrs/industry-state)
2
3Immutable state for your factories.
4
5## Requirements
6
7This extension requires that the factory function returns a stateful object.
8
9## Usage
10
11```js
12import { factory } from "industry"
13import { functions } from "industry-functions"
14import { instance } from "industry-instance"
15import { standard_io } from "industry-standard-io"
16import { state } from "industry-state"
17
18class Test {
19 init() {
20 this.state({ a: 1 })
21 }
22
23 a({ state: { a } }) {
24 return a
25 }
26}
27
28let test = factory(Test)
29 .set("functions", functions)
30 .set("instance", instance)
31 .set("state", state)
32 .set("standard_io", standard_io)
33
34test({ b: 2 })
35test().state() // { a: 1, b: 2 }
36test.a() // { value: 1 }
37```