UNPKG

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