Releases: TENSIILE/saborter-react
Releases · TENSIILE/saborter-react
v2.0.0 (March 4th, 2026)
What's Changed
💥 Breaking Changes
- Increases the
saborterversion to 2 majors
✨ New Features
useReusableAborterhook - hook wrapper over theReusableAborterclass
🎯 Usage Example
const aborter = new useReusableAborter();
// Get the current signal
const signal = aborter.signal;
// Attach listeners
signal.addEventListener('abort', () => console.log('Listener 1'));
signal.addEventListener('abort', () => console.log('Listener 2'), { once: true }); // won't be recovered
// Set onabort handler
signal.onabort = () => console.log('Onabort handler');
// First abort
aborter.abort('First reason');
// Output:
// Listener 1
// Listener 2 (once)
// Onabort handler
// The signal is now a fresh one, but the non‑once listeners and onabort are reattached
signal.addEventListener('abort', () => console.log('Listener 3')); // new listener, will survive next abort
// Second abort
aborter.abort('Second reason');
// Output:
// Listener 1
// Onabort handler
// Listener 3📦 Distribution
- Available via npm:
npm install @saborter/react - Available via yarn:
yarn add @saborter/react
Full Changelog: v1.0.0...v2.0.0
v1.0.0 (February 4th, 2026)
What's Changed | 🎉 Initial Release of @saborter/react
✨ New Features
Core Functionality
- useAborter hook -
Saborterinstance wrappedReactAPI
📖 Possibilities
- The
aborterfield always has the same reference to theAborterinstance. - Automatically abort the request when the component is unmounted.
- Automatically unsubscribe from all listeners when the component is unmounted.
🎯 Usage Example
import { useAborter } from '@saborter/react';
const Component = () => {
// Create an Aborter instance via the hook
const { aborter } = useAborter();
// Use for the request
const fetchData = async () => {
try {
const data = await aborter.try((signal) => fetch('/api/data', { signal }));
console.log('Data received:', data);
} catch (error) {
console.error('Request error:', error);
}
};
};📦 Distribution
- Available via npm:
npm install @saborter/react - Available via yarn:
yarn add @saborter/react