@knyt/artisan
v0.4.0
Published
A library of reactive primitives (observables, computed values) with automatic memory management and RxJS interoperability.
Maintainers
Readme
🖌️ A reactive foundation for modern web solutions. Lightweight observables—memory-safe, microtask-optimized, and rigorously type-safe.
This package is part of Knyt, a toolkit designed to simplify modern web development.
Key benefits
- Framework-independent foundation
- Prevents memory leaks by design
- Efficient microtask-based update scheduling
- Comprehensive and reliable TypeScript support
Key Features
Core Reactivity Features
- Automatic memory management – Weak references ensure unused subscriptions are cleaned up to prevent memory leaks
- Observable values – Reactive references that can be subscribed to and updated
- Auto-updating derived values - Computed properties that stay synchronized with their sources
- Optimized change handling - Batches updates efficiently using microtasks
- RxJS interoperability – Smoothly integrates with RxJS and similar observable libraries
Supporting Features
- DOM/CSS type safety - Runtime validation for elements, nodes and CSS rules
- Middleware utilities – Tools for building strongly-typed, async-ready processing pipelines
- Essential utilities - Optimized equality checks, debouncing and TypeScript helpers
Documentation
Documentation is available at knyt.dev, including a guide on observables.
Usage
import { isDocumentFragment, mapRef, ref } from "knyt";
// Create a reactive reference
const count$ = ref(0);
// Create a derived (computed) reference
const label$ = mapRef(count$, (n) => `Count is: ${n}`);
const log = (text: string) => {
console.info(text);
};
// Subscribe to changes
const subscription = label$.subscribe(log);
// Update the original reference
count$.set(2); // Console: Count is: 2Install
You can use this package by installing either the Knyt Toolkit or this standalone package.
Knyt Toolkit:
npm install knytStandalone:
npm install @knyt/artisanUpdates
See the CHANGELOG for a list of changes.
License
This package is licensed under the BSD 3-Clause License.
Open-Source Initiative
This project is supported by Sables Applications LLC as part of its open-source initiatives.
