@delpi/zen-core
v1.0.0
Published
Core library of Zen. Provides core utilities, state management, and shared tools used across other packages in the monorepo.
Readme
@delpi/zen-core
Core library of Zen. Provides core utilities, state management, and shared tools used across other packages in the monorepo.
LIVE DEMO
Installation
npm install @delpi/zen-core
# or
pnpm add @delpi/zen-coreUsage
import { Runtime, createApp, FeatureRegistry } from '@delpi/zen-core';
// Create runtime
const runtime = new Runtime();
runtime.register('logger', console);
// // Subscribe to state changes
// runtime.subscribe(state => console.log('[State Updated]', state));
// // Add a middleware
// runtime.useMiddleware((action, next) => {
// console.log('[Middleware] Action:', action);
// next(action);
// });
// Create features
const features = new FeatureRegistry();
features.register('hello', (rt) => {
const logger = rt.get<Console>('logger');
logger.log('Feature hello enabled');
});
// Enable feature
features.enable('hello', runtime);
// Using createApp with plugins
import type { Plugin } from '@delpi/zen-core';
const plugin: Plugin = (rt) => rt.register('time', Date.now());
const app = createApp([plugin]);
console.log(app.runtime.get('time'));License
MIT
