0.0.4 β€’ Published 4 months ago

infinityflow v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

InfinityFlow πŸš€β™ΎοΈ

npm build coverage

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


Made with ❀️ by Korolevskii Dev