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.
โ
ย Tree Shakeable & Fully Typed
โ
ย CLI
docs site
๐ค Learn about it on the๐ฉโ๐ 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));
}