rxjs-sync-with
v0.0.1
Published
A utility to synchronize RxJS observables with external state.
Readme
rxjs-sync-with
A small RxJS utility to keep a source observable in sync with a change feed. It provides pipeable operators for array state (CRUD) and singleton state.
Features
- Works with any RxJS stream (framework‑agnostic)
- CRUD state manager helper
- Share-replay friendly for UI subscriptions
Install
npm i rxjs-sync-withUsage
Array state (CRUD)
import { syncWith, createCrudManager, type Action } from 'rxjs-sync-with';
const manager = createCrudManager<User>((a, b) => a.id === b.id);
const users$ = fetchUsers$.pipe(syncWith(userChanges$, manager));Singleton state
import { syncWithSingleton } from 'rxjs-sync-with';
const user$ = fetchUser$.pipe(
syncWithSingleton(profileUpdates$, (user, update) => (update ? { ...user, ...update } : user)),
);API
syncWith(changeFeed$, stateManager)syncWithSingleton(changeFeed$, stateManager)createCrudManager(compareWith)
Requirements
- RxJS ^7.8
License
MIT
