0.0.4 β’ Published 4 months ago
infinityflow v0.0.4
InfinityFlow πβΎοΈ
The Ultimate TypeScript State Flow Management Library
InfinityFlow is a lightweight, type-safe, and reactive state flow management library built to handle complex service dependencies, automatic resets, and parallel flows β without breaking a sweat.
Why InfinityFlow?
β
Pure TypeScript, no dependencies
β
Automatic dependency resolution
β
Cancellable flows
β
Debounce support
β
Parallel flows & flow groups
β
Chained dependencies
β
Automatic flow reset on state change
β
Works in browser and Node.js environments
Installation
npm install infinityflow
Quick Start
1. Create Observable States
import { ObservableState } from "infinityflow";
const websocketService = new ObservableState(false);
const microphoneService = new ObservableState(false);
2. Define Your Flow
import { Flow } from "infinityflow";
const microphoneFlow = new Flow({autoReset: true, debounceTime: 1000})
.dependsOn(websocketService, (state) => state === true)
.do(() => console.log("Microphone Activated"));
3. Start Flow
microphoneFlow.start();
websocketService.set(true);
FlowGroups & Parallel Flows
Manage multiple flows together like a pro:
import { FlowGroup } from "infinityflow";
const appFlow = new FlowGroup()
.add(microphoneFlow, 1) // Priority 1
.add(someOtherFlow, 2) // Priority 2
.withCallbacks({
onComplete: () => console.log("App Initialized")
});
appFlow.start();
API
State<T>
.set(value: T)
β Update state.get()
β Get current state.subscribe(callback)
β Observe state changes
ObservableState<T>
extends State<T>
.waitFor(predicate)
β Wait for state to match predicate
Flow
.dependsOn(state, predicate)
β Add dependency.do(action)
β Add action to execute.start()
β Start flow execution.reset()
β Reset flow manually.cancel()
β Cancel running flow
FlowGroup
.add(flow, priority)
β Add flow with priority.start()
β Start all flows.reset()
β Reset all flows.cancel()
β Cancel all flows
What Makes InfinityFlow... Infinite?
β
Infinite state reactivity
β
Zero external dependencies
β
Fully typed, fully reactive, fully awesome
License
MIT