Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2715b3e
Merge pull request #83 from TENSIILE/master
TENSIILE Apr 23, 2026
d959429
feat: adds separate handler methods onCancel and onInterrupt for inte…
TENSIILE Apr 29, 2026
3484317
feat: adds a new event settled to EventListener (#79)
TENSIILE Apr 29, 2026
e52c7f8
fix(changelog): resolve conflicts (#84)
TENSIILE Apr 29, 2026
c6b22f3
Merge pull request #84 from TENSIILE/feature/2.5.0-event-listener-int…
TENSIILE Apr 29, 2026
fa7b1a1
feat: fixes unnecessary calls to the Aborter context inject in Http R…
TENSIILE Apr 29, 2026
efb8d5f
feat: throws response when !response.ok (#85)
TENSIILE Apr 29, 2026
d096d56
feat: adds strict typing for the isAbortError function where the type…
TENSIILE Apr 29, 2026
27b55cf
adds changes to version 2.5.0 to the changelog (#85)
TENSIILE Apr 29, 2026
c81c28b
Merge pull request #85 from TENSIILE/feature/2.5.0-throws-response-ok
TENSIILE Apr 29, 2026
923cd4a
feat(Aborter): adds a debounce option for the try method (#86)
TENSIILE May 2, 2026
686d38a
Merge pull request #86 from TENSIILE/feature/2.5.0-try-debounce
TENSIILE May 2, 2026
2344c58
refactor: corrects jsdoc (#87)
TENSIILE May 4, 2026
443ab9b
feat: adds typing of new handlers for Aborter (#87)
TENSIILE May 4, 2026
5a0ed25
docs(event-listener): adds the event settled to the EventListener doc…
TENSIILE May 4, 2026
d75ebea
fix: fixes debounce issues with Aborter (#87)
TENSIILE May 4, 2026
2647626
adds changes to the changelog (#87)
TENSIILE May 4, 2026
dbcb4eb
docs: updates documentation (#87)
TENSIILE May 4, 2026
541f4ed
Merge pull request #87 from TENSIILE/refactor/2.5.0
TENSIILE May 4, 2026
cfec111
adds a new example of work (#88)
TENSIILE May 15, 2026
f399375
docs(readme): adds debounce to the documentation (#88)
TENSIILE May 15, 2026
5c82203
increases the package version to 2.5.0 (#88)
TENSIILE May 15, 2026
5bbf45c
adds the release date to the changelog (#88)
TENSIILE May 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Saborter Changelog

## v2.5.0 (May 16th, 2026)

### New Features

- Added separate handler methods `onCancel` and `onInterrupt` for interrupting and canceling a request [#84](https://github.com/TENSIILE/saborter/pull/84/changes/d959429fca49fd4fb5c4c0058e117a3d4f1ba6ca)
- Added a new event `settled` to `EventListener` [#84](https://github.com/TENSIILE/saborter/pull/84/changes/34843174ea21c79f83142c328e326cd3dffff3ee)
- Added strict typing for the `isAbortError` function where the typeguard targets `AbortError` [#85](https://github.com/TENSIILE/saborter/pull/85/changes/efb8d5faa5029e580127b447c26ec860284f2fde)
- Added `Response` exception to the `catch` block when `response.ok` is `false` when using the short `fetch` format [#85](https://github.com/TENSIILE/saborter/pull/85/changes/d096d569aadd3ad6c7aa9e1b08a679e41fb0fe49)
- Added `debounce` option directly to `Aborter's` `try` method [#86](https://github.com/TENSIILE/saborter/pull/86/changes)

### Bug Fixes

- Fixed unnecessary calls to the Aborter context inject in Http Request when the provider is disabled [#85](https://github.com/TENSIILE/saborter/pull/85/changes/fa7b1a192e5f94a9caa2b124efdce62e0f619a66)

## v2.4.0 (April 23th, 2026)

### New Features
Expand Down
2 changes: 1 addition & 1 deletion cspell.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "0.2",
"language": "en,ru",
"words": ["Сalls", "Laptev", "saborter", "Saborter", "tgz", "Vladislav", "yxxx", "TENSIILE"],
"words": ["Сalls", "Laptev", "saborter", "Saborter", "tgz", "Vladislav", "yxxx", "TENSIILE", "oninterrupt"],
"flagWords": [],
"ignorePaths": [
"node_modules/**",
Expand Down
12 changes: 7 additions & 5 deletions docs/event-listener.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

## 📖 Overview

The `EventListener` class provides an event management system for handling operation interruption events. It implements the observer pattern for events of types `aborted` and `cancelled`.
The `EventListener` class provides an event management system for handling system interruptions. It implements the observer pattern for events of a certain set of types.

## 📝 Event Types

Two event types are supported:
The following event types are supported:

- **`aborted`** - operation was aborted
- `listener: (error: AbortError): void`
Expand All @@ -16,6 +16,8 @@ Two event types are supported:
- `listener: (data: any): void`
- **`rejected`** - event triggered when an operation fails with an error
- `listener: (error: Error): void`
- **`settled`** - event is triggered when the operation completes, both with an error and successfully
- `listener: (value: { status: 'fulfilled'; value: any; } | { status: 'rejected'; reason: Error }): void`

## 🔧 API

Expand All @@ -27,7 +29,7 @@ Adds an event listener for the specified event type.

**Parameters:**

- `type: 'aborted' | 'cancelled' | 'fulfilled' | 'rejected'` - event type
- `type: 'aborted' | 'cancelled' | 'fulfilled' | 'rejected' | 'settled'` - event type
- `listener: (error: AbortError | Error | any): void` - event handler function

**Returns:** A function to remove the event listener (unsubscribe)
Expand All @@ -49,7 +51,7 @@ Removes an event listener for the specified event type.

**Parameters:**

- `type: 'aborted' | 'cancelled' | 'fulfilled' | 'rejected'` - event type
- `type: 'aborted' | 'cancelled' | 'fulfilled' | 'rejected' | 'settled'` - event type
- `listener: (error: AbortError | Error | any): void` - event handler function to remove

`dispatchEvent(type, error): void`
Expand All @@ -58,7 +60,7 @@ Dispatches an event of the specified type, calling all registered handlers.

**Parameters:**

- `type: 'aborted' | 'cancelled' | 'fulfilled' | 'rejected'` - event type to dispatch
- `type: 'aborted' | 'cancelled' | 'fulfilled' | 'rejected' | 'settled'` - event type to dispatch
- `event: AbortError | Error | any` - event data passed to handlers

**Special Note:** When dispatching `'aborted'` or `'cancelled'` events, the global `onabort` handler is also called.
Expand Down
8 changes: 4 additions & 4 deletions integrations/project/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integrations/project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"react": "^19.2.0",
"react-dom": "^19.2.0",
"saborter": "file:../../unreleased-packages/saborter-2.4.0.tgz"
"saborter": "file:../../unreleased-packages/saborter-2.5.0.tgz"
},
"devDependencies": {
"@eslint/js": "^9.39.1",
Expand Down
13 changes: 7 additions & 6 deletions integrations/project/src/app.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@ const useAborter = <D,>() => {
setData(d);
});

aborter.listeners.addEventListener('rejected', (er) => {
setError(er);
aborter.listeners.addEventListener('rejected', (err) => {
setError(err);
});

aborter.listeners.state.subscribe((s: any) => {
setLoading(s === 'pending');
aborter.listeners.state.subscribe((state) => {
setLoading(state === 'pending');
setError(null);
setData(null);
});
}
},
provision: true
})
);

Expand All @@ -57,7 +58,7 @@ export const App = () => {
const { aborter: postsAborter, data: posts, loading: postsLoading } = useAborter<Post[]>();

const handlePostsLoad = async () => {
postsAborter.try(getPosts, { timeout: 1000 });
postsAborter.try(getPosts, { timeout: 1000, debounce: 2000 });
};

const handleUsersLoad = async () => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "saborter",
"version": "2.4.0",
"version": "2.5.0",
"description": "A simple and efficient library for canceling asynchronous requests using AbortController",
"main": "dist/index.cjs.js",
"module": "dist/index.es.js",
Expand Down
Loading
Loading