Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .changeset/websocket-solid-2-async.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
"@solid-primitives/websocket": major
---

Upgrade to Solid.js 2.0 (`^2.0.0-beta.7`) and add async-reactive message primitives.

**Breaking changes**

- Peer dependency is now `solid-js@^2.0.0-beta.7`. All `createEffect` examples in docs now use the Solid 2.0 split form: `createEffect(compute, effect)`.

**New: `createWSMessage<T>`**

Reactive `Accessor<T | undefined>` for the most recently received WebSocket message. Cleans up its event listener on owner disposal via `onCleanup`.

```ts
const message = createWSMessage<string>(ws);
return <p>{message()}</p>;
```

> Note: uses a signal internally, so under burst conditions only the final message before a flush is tracked by effects. For every-message processing, use the planned `wsMessageIterable` / `createWSData` primitives.

**`createWSState` signal fix**

Internal signal now uses `{ ownedWrite: true }` to suppress the Solid 2.0 dev-mode `SIGNAL_WRITE_IN_OWNED_SCOPE` diagnostic, which would fire if `ws.close()` is called from inside a component body or reactive computation.

**Planned for next minor: async message primitives**

The following are designed and documented but not yet implemented, based on Solid 2.0's `createMemo(AsyncIterable)` model:

- `wsMessageIterable<T>` — buffered `AsyncIterable` that never drops burst messages; works with `makeReconnectingWS`
- `createWSData<T>` — async memo over `wsMessageIterable`; suspends `<Loading>` until first message; integrates with `isPending` and `latest`
- `createWSStore<T>` — reactive store driven by WS messages as draft-mutation patches via `createStore(fn, seed)`
2 changes: 1 addition & 1 deletion packages/match/dev/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, createSignal } from "solid-js";
import { type Component, createSignal } from "solid-js";
import { MatchTag, MatchValue } from "../src/index.js";

type AnimalDog = { type: "dog"; breed: string };
Expand Down
2 changes: 1 addition & 1 deletion packages/memo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ The lazy memo, as it is implemented now, doesn't allow for setting a `equals` fu

### Not ownerless

Lazy memos in Solid 2.0 will be ownerless — the reactive context of the callback will depend of the place of read, not creation.
Lazy memos in Solid will be ownerless — the reactive context of the callback will depend of the place of read, not creation.

This implementation will always execute it's callback with the context of owner it was created under. So ti won't work with [Suspense](https://www.solidjs.com/docs/latest/api#<suspense>) the way you might expect — meaning that it won't activate any Suspense that is below place of creation.

Expand Down
2 changes: 1 addition & 1 deletion packages/mouse/dev/components.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { access, MaybeAccessor } from "@solid-primitives/utils";
import { access, type MaybeAccessor } from "@solid-primitives/utils";
import { type Component, For } from "solid-js";

export const DisplayRecord: Component<{ record: Record<string, MaybeAccessor<any>> }> = props => (
Expand Down
9 changes: 9 additions & 0 deletions packages/websocket/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @solid-primitives/websocket

## 2.0.0-beta.0

### Major Changes

- Upgrade to Solid.js 2.0 (`^2.0.0-beta.7`).
- `createWSState`: signal now uses `ownedWrite: true` to suppress dev-mode warnings when `ws.close()` is called from within a component or effect.
- New primitive `createWSMessage<T>`: reactive signal containing the latest received WebSocket message. Cleans up its event listener automatically on owner disposal.
- Updated all JSDoc examples to use the Solid 2.0 split `createEffect(compute, effect)` form.

## 1.3.2

### Patch Changes
Expand Down
Loading