Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/worktile/store
π A mini, yet powerful state management library for Angular.
https://github.com/worktile/store
Last synced: 5 days ago
JSON representation
π A mini, yet powerful state management library for Angular.
- Host: GitHub
- URL: https://github.com/worktile/store
- Owner: worktile
- License: mit
- Created: 2018-09-22T01:02:03.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-21T06:26:47.000Z (4 months ago)
- Last Synced: 2024-08-22T03:27:00.487Z (4 months ago)
- Language: TypeScript
- Homepage: https://worktile.github.io/store/
- Size: 3.87 MB
- Stars: 60
- Watchers: 10
- Forks: 9
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-angular - @tethys/store - A mini, yet powerful state management library for Angular. (Table of contents / Third Party Components)
- fucking-awesome-angular - @tethys/store - A mini, yet powerful state management library for Angular. (Table of contents / Third Party Components)
- fucking-awesome-angular - @tethys/store - A mini, yet powerful state management library for Angular. (Table of contents / Third Party Components)
- fucking-awesome-angular - @tethys/store - A mini, yet powerful state management library for Angular. (Table of contents / Third Party Components)
README
## @tethys/store
[![GitHubActionCI](https://img.shields.io/github/workflow/status/tethys-org/store/ci-tethys-store-test)](https://github.com/tethys-org/store/actions/workflows/main.yml)
[![Coverage Status][coveralls-image]][coveralls-url]
![](https://img.shields.io/badge/Made%20with%20Angular-red?logo=angular)
[![npm (scoped)](https://img.shields.io/npm/v/@tethys/store?style=flat)](https://www.npmjs.com/package/@tethys/store)
[![npm](https://img.shields.io/npm/dm/@tethys/store)](https://www.npmjs.com/package/@tethys/store)
[![release](https://img.shields.io/github/release-date/tethys-org/store.svg?style=flat
)](https://github.com/atinc/ngx-tethys)
[![docgeni](https://img.shields.io/badge/docs%20by-docgeni-348fe4)](https://github.com/docgeni/docgeni)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)[coveralls-image]: https://coveralls.io/repos/github/tethys-org/store/badge.svg?branch=master
[coveralls-url]: https://coveralls.io/github/tethys-org/storeA mini, yet powerful state management library for Angular.
English | [δΈζζζ‘£](https://github.com/worktile/store/blob/master/README.zh-CN.md)
## Features
- Angular Styled, Store as a Service
- DDD, multi-store model, each store belongs to a domain, state storage and actions are together
- Easy to use API without excessive learning cost## Installation
```
npm install @tethys/store --save
# or if you are using yarn
yarn add @tethys/store
```## Simple Usage
```ts
import { Injectable } from '@angular/core';
import { Action, Store } from '@tethys/store';
import { of } from 'rxjs';
import { tap } from 'rxjs/operators';interface CounterState {
count: number;
}@Injectable()
export class CounterStore extends Store {
static countSelector(state: CounterState) {
return state.count;
}constructor() {
super({ count: 0 });
}@Action()
increase() {
return of(true).pipe(
tap(() => {
this.update({ count: this.snapshot.count + 1 });
})
);
}@Action()
decrease() {
return of(true).pipe(
tap(() => {
this.update((state) => {
return {
count: state.count - 1
};
});
})
);
}
}
``````ts
@Component({
selector: 'thy-store-counter-example',
template: `Count: {{ count$ | async }}
+
-
`,
styleUrls: ['./counter.component.scss']
})
export class ThyStoreCounterExampleComponent implements OnInit {
count$: Observable = this.counterStore.select$(CounterStore.countSelector);constructor(public counterStore: CounterStore) {}
ngOnInit(): void {}
increase() {
this.counterStore.increase();
}decrease() {
this.counterStore.decrease();
}
}
```
## Documentation- [Introduce](https://worktile.github.io/store/guides/intro)
- [Getting Started](https://worktile.github.io/store/guides/getting-started)
- [Store](https://worktile.github.io/store/guides/basic/store)
- [Entity Store](https://worktile.github.io/store/guides/advanced/entity-store)
- [Entity Store with References](https://worktile.github.io/store/guides/advanced/entity-store-references)
- [FAQ](https://worktile.github.io/store/guides/faq)## Development
```base
$ git clone https://github.com/worktile/store
$ cd store && yarn
$ yarn start:docs // open http://localhost:8887
```## Release & Publish
```
yarn release
yarn pub
```
## LICENSE[MIT License](https://github.com/worktile/store/blob/master/LICENSE)