1 | # IndustryState [![Build Status](https://travis-ci.org/invrs/industry-state.svg?branch=master)](https://travis-ci.org/invrs/industry-state)
|
2 |
|
3 | Allows [Industry](https://github.com/invrs/industry) factory functions to receive one or more objects that update state.
|
4 |
|
5 | ## Requirements
|
6 |
|
7 | This extension requires that the factory function returns a stateful object.
|
8 |
|
9 | At Inverse, we usually pair this extension with [IndustryFactoryInstance](https://github.com/invrs/industry-instance).
|
10 |
|
11 | ## Usage
|
12 |
|
13 | ```js
|
14 | import { factory } from "industry"
|
15 | import { instance } from "industry-instance"
|
16 | import { state } from "industry-state"
|
17 |
|
18 | let test = factory()
|
19 | .set("instance", instance)
|
20 | .set("state", state)
|
21 | .base(class {
|
22 | constructor() {
|
23 | this.stateful()
|
24 | }
|
25 | })
|
26 |
|
27 | test({ a: 1, b: 2 })
|
28 | test().state() // { a: 1, b: 2 }
|
29 | test({ c: 3 }, { d: 4 })
|
30 | test().state() // { a: 1, b: 2, c: 3, d: 4 }
|
31 | ```
|