@ngneat/elf
Advanced tools
Comparing version 1.0.0-beta.2 to 1.0.0-beta.3
{ | ||
"name": "@ngneat/elf", | ||
"version": "1.0.0-beta.2", | ||
"version": "1.0.0-beta.3", | ||
"description": "A reactive state management for JS applications", | ||
@@ -32,3 +32,3 @@ "publishConfig": { | ||
"peerDependencies": { | ||
"rxjs": "*" | ||
"typescript": ">= 4.1.2" | ||
}, | ||
@@ -38,2 +38,2 @@ "main": "./store.umd.js", | ||
"typings": "./index.d.ts" | ||
} | ||
} |
107
README.md
@@ -5,72 +5,73 @@ <p align="center"> | ||
> A Reactive Store with Magical Powers (wip) | ||
# Elf | ||
[comment]: <> (Elf is a reactive immutable state management solution built on top of RxJS. It uses custom RxJS operators to query the state and pure functions to update it.) | ||
> A Reactive Store with Magical Powers | ||
[comment]: <> (Elf encourages simplicity. It eases the hassle of creating boilerplate code and comes with robust tools, suitable for both experienced and inexperienced developers.) | ||
Elf is a reactive immutable state management solution built on top of RxJS. It uses custom RxJS operators to query the state and pure functions to update it. | ||
[comment]: <> ([![@ngneat/elf](https://github.com/ngneat/elf/actions/workflows/ci.yml/badge.svg)](https://github.com/ngneat/elf/actions/workflows/ci.yml)) | ||
Elf encourages simplicity. It eases the hassle of creating boilerplate code and comes with robust tools, suitable for both experienced and inexperienced developers. | ||
[comment]: <> ([![commitizen](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)]()) | ||
✅ Modular by design | ||
✅ Tree Shakeable & Fully Typed | ||
✅ CLI | ||
✅ First Class Entities Support | ||
✅ Requests Status & Cache | ||
✅ Persist State | ||
✅ State History | ||
✅ Pagination | ||
✅ Devtools | ||
[comment]: <> ([![PRs](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)]()) | ||
[comment]: <> ([![coc-badge](https://img.shields.io/badge/codeof-conduct-ff69b4.svg?style=flat-square)]()) | ||
<hr /> | ||
[comment]: <> ([![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e5079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)) | ||
<p align="center"> | ||
[comment]: <> ([![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)) | ||
[![@ngneat/elf](https://github.com/ngneat/elf/actions/workflows/ci.yml/badge.svg)](https://github.com/ngneat/elf/actions/workflows/ci.yml) | ||
[![commitizen](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)]() | ||
[![PRs](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)]() | ||
[![coc-badge](https://img.shields.io/badge/codeof-conduct-ff69b4.svg?style=flat-square)]() | ||
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e5079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release) | ||
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) | ||
</p> | ||
[comment]: <> (## Features) | ||
## 🤓 Learn about it on the [docs site](https://ngneat.github.io/elf/) | ||
## 👩🎓 Check out the React Todos [example](https://stackblitz.com/edit/react-ts-jidhej?file=todos/todos.tsx) | ||
## 😋 Check out the Angular Todos [example](https://stackblitz.com/edit/angular-ivy-sky1gb?file=src/app/todos/state/todos.repository.ts) | ||
[comment]: <> (☑️ Modular by design <br>) | ||
<br > | ||
[comment]: <> (☑️ Tree Shakeable & Fully Typed <br>) | ||
```ts | ||
import { Store, createState, withProps, select } from '@ngneat/elf'; | ||
import { withEntities, selectAll, setEntities } from '@ngneat/elf-entities'; | ||
[comment]: <> (☑️ CLI <br>) | ||
interface TodosProps { | ||
filter: 'ALL' | 'ACTIVE' | 'COMPLETED'; | ||
} | ||
[comment]: <> (☑️ First Class Entities Support<br>) | ||
interface Todo { | ||
id: string; | ||
title: string; | ||
status: string; | ||
} | ||
[comment]: <> (☑️ Requests Status & Cache <br>) | ||
const { state, config } = createState( | ||
withProps<TodosProps>({ filter: 'ALL' }), | ||
withEntities<Todo>() | ||
); | ||
[comment]: <> (☑️ Persist State<br>) | ||
const store = new Store({ name: 'todos', state, config }); | ||
[comment]: <> (☑️ State History<br>) | ||
export const filter$ = store.pipe(select(({ filter }) => filter)); | ||
export const todos$ = store.pipe(selectAll()); | ||
[comment]: <> (☑️ Pagination<br>) | ||
export function setTodos(todos: Todo[]) { | ||
store.reduce(setEntities(todos)); | ||
} | ||
[comment]: <> (☑️ Devtools) | ||
[comment]: <> (```ts) | ||
[comment]: <> (import { Store, createState, withProps, select } from '@ngneat/elf';) | ||
[comment]: <> (interface AuthProps {) | ||
[comment]: <> ( user: { id: string } | null;) | ||
[comment]: <> (}) | ||
[comment]: <> (const { state, config } = createState(withProps<AuthProps>({ user: null }));) | ||
[comment]: <> (const authStore = new Store({ state, name, config });) | ||
[comment]: <> (class AuthRepository {) | ||
[comment]: <> ( user$ = authStore.pipe(select((state) => state.user));) | ||
[comment]: <> ( updateUser(user: AuthProps['user']) {) | ||
[comment]: <> ( authStore.reduce((state) => ({) | ||
[comment]: <> ( ...state,) | ||
[comment]: <> ( user: { id: 'Elf' },) | ||
[comment]: <> ( }));) | ||
[comment]: <> ( }) | ||
[comment]: <> (}) | ||
[comment]: <> (```) | ||
export function updateFilter(filter: TodosProps['filter']) { | ||
store.reduce(state => ({ | ||
...state, | ||
filter | ||
})); | ||
} | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77
31578