Skip to content
Open
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
7 changes: 3 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ on:

jobs:
build:
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}
name: Build, lint, and test on Node 24 and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ["20", "22"]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
Expand All @@ -24,10 +23,10 @@ jobs:
with:
bun-version: latest

- name: Setup Node.js ${{ matrix.node }}
- name: Setup Node.js 24
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
node-version: "24"

- name: Install dependencies
run: bun install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup Node.js for npm publish
uses: actions/setup-node@v4
with:
node-version: "20"
node-version: "24"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: bun install
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ jobs:
with:
bun-version: latest

- name: Setup Node.js 24
uses: actions/setup-node@v4
with:
node-version: "24"

- name: Install dependencies
run: bun install

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @spiko-tech/effect-react-query

## 2.0.0

### Major Changes

- [#18](https://github.com/spiko-tech/effect-react-query/pull/18) [`256d45b`](https://github.com/spiko-tech/effect-react-query/commit/256d45bb05d882b671c71182dd041cd8ec6b4e2d) Thanks [@antomorel](https://github.com/antomorel)! - Migrate to Effect v4. The `runtime` option now accepts a `Context.Context<R>` or a `ManagedRuntime` (v3 `Runtime.Runtime<R>` no longer exists). Cancellation uses Effect's native `signal` run option.

## 1.1.3

### Patch Changes
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ pnpm add @effect-react-query

```ts
import { useEffectQuery, useEffectMutation } from "@effect-react-query";
import { Effect, Schema, Match } from "effect";
import * as Effect from "effect/Effect";
import * as Schema from "effect/Schema";
import * as Match from "effect/Match";

// Define typed errors
class NetworkError extends Schema.TaggedError<NetworkError>()("NetworkError", {
Expand Down
32 changes: 14 additions & 18 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const query = useEffectQuery({
| Option | Description |
| --------- | ----------------------------------------------------------------------------- |
| `queryFn` | `(context: QueryFunctionContext) => Effect.Effect<TData, TError, R>` |
| `runtime` | Required when Effect has service requirements (`Runtime` or `ManagedRuntime`) |
| `runtime` | Required when Effect has service requirements (`Context` or `ManagedRuntime`) |
| `...` | All standard React Query options (`staleTime`, `gcTime`, `retry`, etc.) |

### With Runtime Dependencies
Expand Down Expand Up @@ -188,7 +188,7 @@ mutation.mutate({ name: "John", email: "john@example.com" });
| Option | Description |
| ------------ | ----------------------------------------------------------------------------- |
| `mutationFn` | `(variables: TVariables) => Effect.Effect<TData, TError, R>` |
| `runtime` | Required when Effect has service requirements (`Runtime` or `ManagedRuntime`) |
| `runtime` | Required when Effect has service requirements (`Context` or `ManagedRuntime`) |
| `onError` | Callback on error (receives typed error) |
| `...` | All standard React Query mutation options |

Expand Down Expand Up @@ -308,7 +308,8 @@ await queryClient.fetchQuery(toQueryOptions(protectedQueryOptions("123")));
Errors retain their typed structure and can be matched using Effect's `Match.valueTags`:

```ts
import { Schema, Match } from "effect";
import * as Schema from "effect/Schema";
import * as Match from "effect/Match";
import { useEffectQuery } from "@effect-react-query";

// Define typed errors
Expand Down Expand Up @@ -349,17 +350,20 @@ const mutation = useEffectMutation({

# Dependency Injection

When Effects have service requirements, provide a `ManagedRuntime` or `Runtime`:
When Effects have service requirements, provide a `ManagedRuntime` or a `Context`:

```ts
import { Context, Effect, Layer, ManagedRuntime } from "effect";
import * as Context from "effect/Context";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import * as ManagedRuntime from "effect/ManagedRuntime";
import { useEffectQuery } from "@effect-react-query";

// Define a service
class UserService extends Context.Tag("UserService")<
class UserService extends Context.Service<
UserService,
{ readonly getUser: (id: string) => Effect.Effect<User, NetworkError> }
>() {}
>()("UserService") {}

// Create the layer
const UserServiceLive = Layer.succeed(
Expand Down
Loading
Loading