Skip to content

refactor(supabase): drop rxdart dependency - #1569

Merged
spydon merged 1 commit into
mainfrom
refactor/supabase-drop-rxdart
Jul 9, 2026
Merged

spydon merged 1 commit into
mainfrom
refactor/supabase-drop-rxdart

Conversation

@spydon

@spydon spydon commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What

Removes the rxdart dependency from the supabase package. It was used in exactly one place: SupabaseStreamBuilder, which backed its stream controllers with rxdart's BehaviorSubject.

They are replaced with a small, private _BehaviorSubject<T> built on top of the standard dart:async primitives (StreamController.broadcast + Stream.multi).

Why

rxdart was pulling in a whole reactive-extensions library for a single feature: latest-value replay for late subscribers. This mirrors what #1566 already did for gotrue, and removes rxdart from the monorepo entirely.

Note: #1566 only dropped rxdart from gotrue; the supabase package used it independently, and #1567 merely bumped its version constraint.

Preserved behavior

  • Latest-value replay — a new subscriber immediately receives the last emitted event on .listen().
  • Error propagation — errors are still emitted as stream errors (and the last error is replayed to late subscribers).
  • Broadcast semantics — multiple simultaneous listeners.
  • onListen / onCancel lifecycle hooks used to lazily start/tear down the realtime + postgrest fetch.

Testing

dart analyze clean and all supabase package tests pass (mock_test.dart, client_test.dart).

Removes the last remaining rxdart usage in the monorepo. The supabase
package only used rxdart's BehaviorSubject in SupabaseStreamBuilder for
latest-value replay to late subscribers.

Replaces it with a small private _BehaviorSubject built on dart:async
primitives (StreamController.broadcast + Stream.multi), matching the
approach already used in gotrue (#1566).
@spydon
spydon merged commit 51dcf0f into main Jul 9, 2026
33 checks passed
@spydon
spydon deleted the refactor/supabase-drop-rxdart branch July 9, 2026 13:49
spydon added a commit that referenced this pull request Jul 9, 2026
## What

Introduces a new published `supabase_common` package and moves the
**non-breaking** shared/duplicated code from #1572 into it.

**Stacked:** `main` ← #1569 (drop rxdart) ← #1571 (drop retry, in-house
helper) ← **this PR**.

> [!NOTE]
> Review/merge in stack order. Retarget this PR's base as each parent
merges (→ `refactor/inline-retry`, then `refactor/supabase-drop-rxdart`,
then `main`).

## Moved into `supabase_common`

| Item | Was |
|------|-----|
| `ToSnakeCase` enum extension | duplicated (byte-for-byte) in `gotrue`
+ `storage_client` |
| Platform detection (`platform_io`/`platform_stub`) | duplicated in
`supabase` + `supabase_flutter` (kept the extra
`isRunningInFlutterTest`) |
| `buildClientInfoHeader` (`X-Client-Info`) | built in all 7 client
packages (simple + platform-aware forms) |
| `isSuccessStatusCode` (2xx) | inlined/duplicated in `gotrue`,
`storage_client`, `postgrest`, `functions_client` |
| `FetchOptions` | duplicated internally in `gotrue` + `storage_client`
|
| `Base64Url` / PKCE / uuid helpers | `gotrue`-only; also fixes an
intra-`gotrue` duplication in `jwt.dart` |
| `ReplaySubject` | unifies gotrue's `_ReplaySubject` and supabase's
`_BehaviorSubject` |
| `retry` / `RetryOptions` helper | the in-house copy #1571 added to
`gotrue` + `storage_client` (identical); `@internal` dropped since it is
now used across packages |

## Not included

- **Tier 3** (shared exception base, HTTP fetch wrappers, `RetryTimer`)
— breaking, tracked under v3 (#1278).

## Notes

- `supabase_common` is an internal, published package (client packages
cannot depend on an unpublished local package). Its README flags it as
internal with breaking changes expected.
- Registered in the workspace, `test.yml` (`DART_PACKAGES` + Coveralls
carryforward), and `release-pana.yml`.
- No public API changes: every moved symbol was either internal or
re-exported so consumers importing from the client packages are
unaffected.

## Verification

- `dart analyze` clean across the whole workspace.
- `supabase_common` unit tests pass (ToSnakeCase, client-info header,
isSuccessStatusCode, Base64Url, PKCE, uuid, ReplaySubject
sync/async/replay/hooks/addStream, retry).
- `gotrue` (constants/helper), `functions_client` (full suite), and
`supabase` (utilities) tests pass locally. Backend-dependent suites run
in CI.

Refs #1572
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants