ngneat / elf

πŸ§™β€β™€οΈ A Reactive Store with Magical Powers

Home Page:https://ngneat.github.io/elf/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Elf

A Reactive Store with Magical Powers

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.

Elf encourages simplicity. It saves you the hassle of creating boilerplate code and offers powerful tools with a moderate learning curve, suitable for experienced and inexperienced developers alike.

βœ…  Modular by design
βœ…  Tree Shakeable & Fully Typed
βœ…  CLI
βœ…  First Class Entities Support
βœ…  Requests Status & Cache
βœ…  Persist State
βœ…  State History
βœ…  Pagination
βœ…  Devtools


@ngneat/elf commitizen PRs coc-badge semantic-release styled with prettier

πŸ€“ Learn about it on the docs site

πŸ‘©β€πŸŽ“ Check out the React Todos example

πŸ˜‹ Check out the Angular Todos example or Books example


import { createStore, withProps, select, setProp } from '@ngneat/elf';
import { withEntities, selectAllEntities, setEntities } from '@ngneat/elf-entities';

interface TodosProps {
  filter: 'ALL' | 'ACTIVE' | 'COMPLETED';
}

interface Todo {
  id: string;
  title: string;
  status: string;
}

const store = createStore(
  { name: 'todos' },
  withProps<TodosProps>({ filter: 'ALL' }),
  withEntities<Todo>()
);

export const filter$ = store.pipe(select(({ filter }) => filter));
export const todos$ = store.pipe(selectAllEntities());

export function setTodos(todos: Todo[]) {
  store.update(setEntities(todos));
}

export function updateFilter(filter: TodosProps['filter']) {
  store.update(setProp('filter', filter));
}

πŸ—’οΈ Review the Change Logs

⭐ Usage Trend of Elf Packages

Usage Trend of Elf Packages

About

πŸ§™β€β™€οΈ A Reactive Store with Magical Powers

https://ngneat.github.io/elf/

License:MIT License


Languages

Language:TypeScript 96.2%Language:HTML 2.1%Language:SCSS 1.0%Language:JavaScript 0.6%Language:Shell 0.0%Language:Batchfile 0.0%