https://github.com/invrs/industry-state
Immutable state for your factories
https://github.com/invrs/industry-state
Last synced: 22 days ago
JSON representation
Immutable state for your factories
- Host: GitHub
- URL: https://github.com/invrs/industry-state
- Owner: invrs
- Created: 2016-02-19T21:43:55.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-06-11T06:53:41.000Z (about 10 years ago)
- Last Synced: 2025-10-30T07:02:46.742Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 7
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# IndustryState [](https://travis-ci.org/invrs/industry-state)
Immutable state for your factories.
## Requirements
This extension requires that the factory function returns a stateful object.
## Usage
```js
import { factory } from "industry"
import { functions } from "industry-functions"
import { instance } from "industry-instance"
import { standard_io } from "industry-standard-io"
import { state } from "industry-state"
class Test {
init() {
this.state({ a: 1 })
}
a({ state: { a } }) {
return a
}
}
let test = factory(Test)
.set("functions", functions)
.set("instance", instance)
.set("state", state)
.set("standard_io", standard_io)
test({ b: 2 })
test().state() // { a: 1, b: 2 }
test.a() // { value: 1 }
```