Skip to content

upgrade: connectivity package upgrade for Solid 2.0#931

Merged
davedbase merged 3 commits into
solidjs-community:nextfrom
davedbase:update/v2/connectivity
Jun 9, 2026
Merged

upgrade: connectivity package upgrade for Solid 2.0#931
davedbase merged 3 commits into
solidjs-community:nextfrom
davedbase:update/v2/connectivity

Conversation

@davedbase

@davedbase davedbase commented Jun 8, 2026

Copy link
Copy Markdown
Member

Solid 2.0 migration**

  • Updated peer/dev deps to solid-js@^2.0.0-beta.14 and @solidjs/web@^2.0.0-beta.14
  • isServer import moved from solid-js/web@solidjs/web
  • Internal signal uses ownedWrite: true so the event-listener setter can be called from within reactive scopes (e.g. synchronous dispatchEvent in tests) without throwing SIGNAL_WRITE_IN_OWNED_SCOPE
  • Tests updated with flush() after signal writes to account for Solid 2.0's async batching

New: Network Information API primitives

  • makeNetworkInformation(callback) — low-level listener combining window online/offline events with navigator.connection change events; fires a NetworkState snapshot on any change
  • createNetworkInformation(){ online, downlink, downlinkMax, effectiveType, rtt, saveData, type } — independent reactive signals for the full network state; suitable for adaptive loading (image quality, prefetch, feature flags based on connection conditions)
  • useNetworkInformation() — singleton-root variant sharing a single listener set across all callers
  • Exported types: NetworkState, NetworkInformationReturn, EffectiveConnectionType, ConnectionType
  • navigator.connection augmented via declare global (not in TypeScript 5.8's stdlib)
  • Network Information API fields return undefined gracefully in Firefox/Safari — no errors thrown

Stories

  • Three Storybook demos under Network/Connectivity:
    • Online / offline status — live createConnectivitySignal badge
    • Connection quality signals — full createNetworkInformation panel with adaptive quality indicator
    • Network change logmakeNetworkInformation callback log with timestamps
  • Removed the old dev/index.tsx example
  • README: added Storybook docs link at top, removed old CodeSandbox demo link

Summary by CodeRabbit

Release Notes

  • New Features

    • Added Network Information API–based primitives for monitoring network state details including connection quality metrics, effective connection type, downlink speed, round-trip time, and data-saving preferences
    • Three primitive variants available: callback-based listener, reactive signal-based accessors, and singleton root
  • Documentation

    • Updated package documentation with comprehensive guides, usage examples, and browser support information

@davedbase davedbase added this to the Solid 2.0 Migration milestone Jun 8, 2026
@changeset-bot

changeset-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 86f22e2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solid-primitives/connectivity Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9ab91c1c-3269-49bd-8e0e-42ad9f17a293

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@davedbase davedbase changed the title Migrated and improved connectivity primitive upgrade: connectivity package upgrade for Solid 2.0 Jun 8, 2026
@davedbase davedbase marked this pull request as ready for review June 8, 2026 16:54

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/connectivity/src/index.ts (1)

211-219: ⚡ Quick win

Inconsistent signal setter pattern.

Line 212 passes the value directly to setOnline(state.online), while lines 213–218 wrap each value in an arrow function: setDownlink(() => state.downlink). Both patterns work (Solid accepts values or updater functions), but the inconsistency is confusing.

For clarity and brevity, use the direct-value pattern consistently across all setters.

♻️ Proposed fix for consistency
   makeNetworkInformation(state => {
     setOnline(state.online);
-    setDownlink(() => state.downlink);
-    setDownlinkMax(() => state.downlinkMax);
-    setEffectiveType(() => state.effectiveType);
-    setRtt(() => state.rtt);
-    setSaveData(() => state.saveData);
-    setType(() => state.type);
+    setDownlink(state.downlink);
+    setDownlinkMax(state.downlinkMax);
+    setEffectiveType(state.effectiveType);
+    setRtt(state.rtt);
+    setSaveData(state.saveData);
+    setType(state.type);
   });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/connectivity/src/index.ts` around lines 211 - 219, The setters in
the makeNetworkInformation callback use mixed patterns: setOnline(state.online)
vs setDownlink(() => state.downlink) etc.; make them consistent by passing the
direct value for all signals (use setDownlink(state.downlink),
setDownlinkMax(state.downlinkMax), setEffectiveType(state.effectiveType),
setRtt(state.rtt), setSaveData(state.saveData), setType(state.type)) while
leaving makeNetworkInformation and setOnline unchanged so all signals use the
same direct-value update style.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/connectivity/src/index.ts`:
- Around line 211-219: The setters in the makeNetworkInformation callback use
mixed patterns: setOnline(state.online) vs setDownlink(() => state.downlink)
etc.; make them consistent by passing the direct value for all signals (use
setDownlink(state.downlink), setDownlinkMax(state.downlinkMax),
setEffectiveType(state.effectiveType), setRtt(state.rtt),
setSaveData(state.saveData), setType(state.type)) while leaving
makeNetworkInformation and setOnline unchanged so all signals use the same
direct-value update style.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b4bb0b60-17da-49a2-92f7-db8d5937a35a

📥 Commits

Reviewing files that changed from the base of the PR and between 48f3bbb and 6f25a4a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • .changeset/connectivity-solid2-migration.md
  • packages/connectivity/README.md
  • packages/connectivity/dev/index.tsx
  • packages/connectivity/package.json
  • packages/connectivity/src/index.ts
  • packages/connectivity/stories/connectivity.stories.tsx
  • packages/connectivity/stories/tsconfig.json
  • packages/connectivity/test/index.test.ts
  • packages/connectivity/test/server.test.ts
  • packages/connectivity/test/setup.ts
💤 Files with no reviewable changes (1)
  • packages/connectivity/dev/index.tsx

@davedbase davedbase merged commit 9185800 into solidjs-community:next Jun 9, 2026
1 check passed
@davedbase davedbase deleted the update/v2/connectivity branch June 9, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants