Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
Apr 11, 2021
Sep 12, 2021
Aug 25, 2021
Aug 10, 2021
Apr 11, 2021

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 { Store, createState, withProps, select } from '@ngneat/elf';
import { withEntities, selectAll, setEntities } from '@ngneat/elf-entities';

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

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

const { state, config } = createState(
  withProps<TodosProps>({ filter: 'ALL' }),
  withEntities<Todo>()
);

const store = new Store({ name: 'todos', state, config });

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

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

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