Skip to main content
Home
This package has been archived, and as such it is read-only.

Built and signed on GitHub Actions

Works with
This package works with Node.js, Deno, BrowsersIt is unknown whether this package works with Cloudflare Workers, Bun
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
This package works with Browsers
JSR Score100%
Downloads1/wk
Publisheda month ago (0.2.0)

A lightweight, RxJS-inspired library implementing the Observer pattern in JavaScript. Features AsyncSubjects with AbortController-based unsubscription, supporting both synchronous and asynchronous producers.

@xan/async-subject

A set of tooling that encapsulates an object that acts as a variant of Subject to be used if you only care about the final nexted value (if any) before return.

Build

Automated by JSR.

Publishing

Automated by .github\workflows\publish.yml.

Running unit tests

Run deno task test or deno task test:ci to execute the unit tests via Deno.

Example

import { AsyncSubject } from "@xan/async-subject";
import { Observer } from "@xan/observer";

const subject = new AsyncSubject<number>();
subject.next(1);
subject.next(2);

subject.subscribe(new Observer((value) => console.log(value)));

subject.next(3);

subject.return(); // Console output: 3

subject.subscribe(new Observer((value) => console.log(value))); // Console output: 3

Glossary And Semantics

Built and signed on
GitHub Actions

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@xan/async-subject

Import symbol

import * as async_subject from "@xan/async-subject";
or

Import directly with a jsr specifier

import * as async_subject from "jsr:@xan/async-subject";

Add Package

pnpm i jsr:@xan/async-subject
or (using pnpm 10.8 or older)
pnpm dlx jsr add @xan/async-subject

Import symbol

import * as async_subject from "@xan/async-subject";

Add Package

yarn add jsr:@xan/async-subject
or (using Yarn 4.8 or older)
yarn dlx jsr add @xan/async-subject

Import symbol

import * as async_subject from "@xan/async-subject";

Add Package

vlt install jsr:@xan/async-subject

Import symbol

import * as async_subject from "@xan/async-subject";

Add Package

npx jsr add @xan/async-subject

Import symbol

import * as async_subject from "@xan/async-subject";

Add Package

bunx jsr add @xan/async-subject

Import symbol

import * as async_subject from "@xan/async-subject";