effect-rxdb
v0.1.0
Published
Scoped, typed Effect integration for the RxDB public API.
Readme
effect-rxdb
Documentation: guides and API reference.
Named adapters cover core queries/writes/events, the operational storage API,
attachments, local documents, state, migration, JSON dumps, pipelines, backups,
CRDTs, hooks, and conflict callbacks. Connector subpaths (CouchDB, GraphQL,
Firestore, MongoDB, Supabase, Nats, Appwrite, WebRTC, WebSocket,
GoogleDrive, and OneDrive) acquire native replication states in Effect Scope.
Optional SDKs remain the consumer's dependencies. Newer APIs require native
peer support. Native pure builders, property accessors, and premium factories
are retained rather than copied.
Effect-native RxDB execution, streams, typed failures, scoped database/replication resources, and callback integration. RxDB retains ownership of persistence and synchronization semantics; native handles remain compatible with plugins and TanStack DB.
npm install effect-rxdb effect rxdb rxjsimport { Effect } from "effect";
import { Database, Query } from "effect-rxdb";
import { getRxStorageMemory } from "rxdb/plugins/storage-memory";
import type { RxCollection } from "rxdb";
type Todo = { id: string; title: string };
const program = Effect.scoped(
Effect.gen(function* () {
const db = yield* Database.make<{ todos: RxCollection<Todo> }>({
name: "todos",
storage: getRxStorageMemory(),
multiInstance: false,
});
yield* Database.addCollections(db, {
todos: {
schema: {
version: 0,
primaryKey: "id",
type: "object",
properties: {
id: { type: "string", maxLength: 100 },
title: { type: "string" },
},
required: ["id", "title"],
},
},
});
const documents = yield* Query.find(db.todos);
return documents.map((document) => document.toJSON());
}),
);
await Effect.runPromise(program);Namespaces: Database, Collection, Document, Query, Attachment, Storage, Replication, Callback, Observable, Resource, Interop, Plugin, Migration, LocalDocument, State, JsonDump, Pipeline, Schema, RxError. Every namespace also has a subpath entrypoint.
Specific tagged errors retain native code/cause/parameters. Query.findOne returns Option; Query.stream creates a scoped Stream. Replication.make accepts Effect handlers and retains native replication retries. Interop.call lifts any remaining public RxDB/plugin operation. Plugin.acquire scopes native plugin resources. Native storage factories and third-party integrations remain usable directly.
Supported peers: Effect 4 (compatible candidates from rc.111), RxDB 16.21.1/17.x, RxJS 7. No native engine or premium plugin is bundled. Acquisition is uninterruptible to prevent late-result leaks; native storage writes cannot necessarily be canceled. Bulk operations retain partial success. Incremental modifiers must be replay-safe. Observable bridges are unbounded by default because RxJS cannot provide pull-based backpressure.
Optional application adapters
Application adapters are separate subpath exports; the primitive effect-rxdb
entrypoint does not import them.
| Import | Responsibility | Additional peers |
| ------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| effect-rxdb/http | Effect schema declarations, generated document/attachment clients, Fetch handlers and bounded bodies | None beyond Effect |
| effect-rxdb/replica | Shared native pull scopes, persisted independent checkpoints, readiness and cancellation | RxDB and RxJS |
| effect-rxdb/attachments | Native durable upload replay, digest acknowledgements and demand-driven persisted downloads | RxDB and RxJS |
| effect-rxdb/tanstack | Filtered native queries, cached/empty readiness and durable TanStack mutations | RxDB, RxJS, @tanstack/react-db, @tanstack/rxdb-db-collection |
Native and TanStack peers are optional for HTTP-only consumers. Install the peers for every adapter you use. Authentication, authorization, document schemas, conflict policy, storage providers and deployment bindings belong to the caller. Cloudflare invalidation servers and browser resync hints belong to the host's transport package; they are not loaded by these entrypoints.
