https://github.com/bcherny/typed-store
a strongly typed store with lenses and change subscription
https://github.com/bcherny/typed-store
Last synced: 8 months ago
JSON representation
a strongly typed store with lenses and change subscription
- Host: GitHub
- URL: https://github.com/bcherny/typed-store
- Owner: bcherny
- License: other
- Created: 2015-10-16T02:12:58.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-16T17:03:07.000Z (almost 10 years ago)
- Last Synced: 2024-12-17T03:03:29.845Z (10 months ago)
- Language: JavaScript
- Size: 133 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# typed-store
> a strongly typed store for angular 1.x
**under active development**
## usage
```js
angular.controller('myController', ($scope, Store) => {const t = type.type
$scope.myStore = new Store({
foo: t.number,
bar: t.or(t.string, t.number),
baz: t.instanceOf(Date)
})$scope.myStore.foo = 2 // 2
$scope.myStore.foo // 2
$scope.myStore.foo = [] // TypeError!$scope.$watch('myStore.foo', _ => console.log('foo changed!', _))
})
```## advantages over plain old objects for state
- centralized state store for your entire app
- immutable backing store for cheap state identity and equality checks, free snapshotting, and undo/redo
- mutable facade for easy integration with angular
- typed model for validation
- free model de/serialization for the full app state## building
`npm start`
## developing
`gulp watch`
## running the tests
`npm test`