This package has been archived, and as such it is read-only.
Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
latest
alexanderharding/subjectWorks with
•JSR Score100%•This package works with Node.js, Deno, BrowsersIt is unknown whether this package works with Cloudflare Workers, Bun




Downloads21/wk
•Publisheda month ago (0.2.0)
A lightweight, RxJS-inspired library implementing the Observer pattern in JavaScript. Features Subjects with AbortController-based unsubscription, supporting both synchronous and asynchronous producers.
@xan/subject
A set of tooling that encapsulates an object that acts as both an Observer and Observable.
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 { Subject } from "@xan/subject"; import { from } from "@xan/observable"; class Authenticator { readonly #events = new Subject<Event>(); // Hide the Observer from the public API by exposing the Subject as an Observable. readonly events = from(this.#events); [Symbol.dispose]() { this.#events.return(); // Cleanup resources. } login() { // Execute some login logic... this.#events.next(new Event("login")); } logout() { // Execute some logout logic... this.#events.next(new Event("logout")); } }
Glossary And Semantics
Built and signed on
GitHub Actions
Add Package
deno add jsr:@xan/subject
Import symbol
import * as subject from "@xan/subject";
Import directly with a jsr specifier
import * as subject from "jsr:@xan/subject";
Add Package
pnpm i jsr:@xan/subject
pnpm dlx jsr add @xan/subject
Import symbol
import * as subject from "@xan/subject";
Add Package
yarn add jsr:@xan/subject
yarn dlx jsr add @xan/subject
Import symbol
import * as subject from "@xan/subject";
Add Package
vlt install jsr:@xan/subject
Import symbol
import * as subject from "@xan/subject";
Add Package
npx jsr add @xan/subject
Import symbol
import * as subject from "@xan/subject";
Add Package
bunx jsr add @xan/subject
Import symbol
import * as subject from "@xan/subject";