effect-zero 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +7 -9
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -45,7 +45,7 @@ import * as Server from "effect-zero/server";
45
45
  import * as Schema from "effect/Schema";
46
46
  import * as Effect from "effect/Effect";
47
47
  import postgres from "postgres";
48
- import { clientTransaction } from "./client"; // see below
48
+ import { clientTransaction, clientMutators } from "./client"; // see below
49
49
  import { mutatorSchema } from "./mutators";
50
50
 
51
51
  // zero schema (define or use something like drizzle-zero)
@@ -89,7 +89,8 @@ export const serverMutators = Mutators.make(mutatorSchema, {
89
89
  yield* Effect.log("after the transaction");
90
90
  }),
91
91
  toggle: Effect.fn(function* ({ id, done }) {
92
- yield* serverTransaction.use((tx) => tx.mutate.TodoTable.update({ id, done })).pipe(serverTransaction.execute);
92
+ // You can also reuse client mutators on the server
93
+ yield* clientMutators.todo.toggle({ id, done }).pipe(serverTransaction.execute);
93
94
  }),
94
95
  },
95
96
  });
@@ -121,18 +122,16 @@ import * as Effect from "effect/Effect";
121
122
  import { schema } from "./schema"; // your schema
122
123
  import { mutatorSchema } from "./mutators"; // see below
123
124
 
124
- const clientTransaction = ClientTransaction.make("ClientTransaction", schema);
125
-
126
125
  // The "client-side" transaction
127
- export const clientTransaction = ClientTransaction.make("ClientTransaction", schema);
126
+ const clientTransaction = ClientTransaction.make("ClientTransaction", schema);
128
127
 
129
128
  export const clientMutators = Mutators.make(mutatorSchema, {
130
129
  todo: {
131
130
  create: Effect.fn(function* ({ id, title }) {
132
- yield* zeroClient.Transaction.use((tx) => tx.mutate.TodoTable.insert({ id, title, createdAt: Date.now() }));
131
+ yield* clientTransaction.use((tx) => tx.mutate.TodoTable.insert({ id, title, createdAt: Date.now() }));
133
132
  }),
134
133
  toggle: Effect.fn(function* ({ id, done }) {
135
- yield* zeroClient.Transaction.use((tx) => tx.mutate.TodoTable.update({ id, done }));
134
+ yield* clientTransaction.use((tx) => tx.mutate.TodoTable.update({ id, done }));
136
135
  }),
137
136
  },
138
137
  });
@@ -259,8 +258,7 @@ const todoAtom = Atom.fn(Effect.fn(function* (id: string, get: Atom.FnContext) {
259
258
  });
260
259
  ```
261
260
 
262
- > [!NOTE]
263
- > Queries created via `Query.make` implement the [`Equal` trait](https://effect.website/docs/trait/equal/), so `Atom.query` would properly cache the results when using queries as arguments.
261
+ > **Note:** Queries created via `Query.make` implement the [`Equal` trait](https://effect.website/docs/trait/equal/), so `Atom.family` would properly cache the results when using queries as arguments.
264
262
 
265
263
  ## Differences from the original implementation
266
264
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "effect-zero",
3
3
  "type": "module",
4
- "version": "0.3.0",
4
+ "version": "0.3.1",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "url": "https://github.com/realms-labs/effect-zero"