UNPKG

834 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
23test({ a: 1, b: 2 })
24test().state() // { a: 1, b: 2 }
25test({ c: 3 }, { d: 4 })
26test().state() // { a: 1, b: 2, c: 3, d: 4 }
27```