Skip to content

Pathverse/hihook

Repository files navigation

HiHook

A high-level hook pipeline framework for Dart. Build extensible middleware chains with dependency resolution, conditions, and transactions.

Features

  • Hook Pipeline — Pre/Main/Post phases with priority ordering
  • Dependency Graph — Topological sort with cycle detection
  • Conditions — Composable filters with &, |, ~ operators
  • Transactions — Savepoints and automatic rollback
  • Plugin System — Bundle hooks for reuse

Quick Start

final engine = HiEngine();

// Register a simple hook
engine.register(HiHook(
  uid: 'logger',
  events: ['read', 'write'],
  handler: (payload, ctx) {
    print('${ctx.event}: ${payload.key}');
    return const HiContinue();
  },
));

// Emit an event
await engine.emit('write', HiPayload(key: 'user:1', value: data));

Plugins

// Install pre-built plugins
Base64Plugin().install(engine);  // Encode/decode values
TtlPlugin().install(engine);     // Time-to-live expiration
LruPlugin().install(engine);     // Access tracking

Transactions

await engine.transaction((tx) async {
  await tx.emit('write', payload1, compensate: () => delete(key1));
  await tx.emit('write', payload2, compensate: () => delete(key2));
  // On failure: compensations run in reverse order
});

About

high level abstraction hooks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages