@confect/foldkit 10.0.0-next.22 → 10.0.0-next.24

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.
@@ -44,17 +44,17 @@ const paginatedError = <Query extends Ref.AnyConfectPublicPaginatedQuery>(
44
44
 
45
45
  /**
46
46
  * The dependency record of a `reactiveQuery` entry. `None` means the
47
- * subscription is closed; a change from one `Some` to another tears the
48
- * server subscription down and reopens it with the new args.
47
+ * subscription is closed; a change from one `Some` to another tears the server
48
+ * subscription down and reopens it with the new args.
49
49
  */
50
50
  export interface Dependencies<Query extends Ref.AnyConfectPublicQuery> {
51
51
  readonly args: Option.Option<Ref.Args<Query>>;
52
52
  }
53
53
 
54
54
  /**
55
- * Maps a reactive query's emissions into the app's Messages. Every failure—the ref's typed error, a transport error, or a codec error—arrives via
56
- * `onError`, so the resulting stream's error channel is `never`, as Foldkit
57
- * requires.
55
+ * Maps a reactive query's emissions into the app's Messages. Every failure—the
56
+ * ref's typed error, a transport error, or a codec error—arrives via `onError`,
57
+ * so the resulting stream's error channel is `never`, as Foldkit requires.
58
58
  */
59
59
  export interface Handlers<
60
60
  Query extends Ref.AnyConfectPublicQuery,
@@ -78,13 +78,13 @@ type ArgsConfig<Query extends Ref.AnyConfectPublicQuery, Model> = {
78
78
  });
79
79
 
80
80
  /**
81
- * A `dependenciesToStream` body for a hand-written subscription entry: runs
82
- * the ref as a reactive query against the `Client` resource and maps
83
- * every emission and every failure into a Message. Query failures are values,
84
- * so the subscription remains live and can later emit a successful result.
81
+ * A `dependenciesToStream` body for a hand-written subscription entry: runs the
82
+ * ref as a reactive query against the `Client` resource and maps every emission
83
+ * and every failure into a Message. Query failures are values, so the
84
+ * subscription remains live and can later emit a successful result.
85
85
  *
86
- * Prefer `reactiveQuery`, which builds the whole entry; reach for this when
87
- * you need control over the entry's dependencies (custom gating, extra
86
+ * Prefer `reactiveQuery`, which builds the whole entry; reach for this when you
87
+ * need control over the entry's dependencies (custom gating, extra
88
88
  * dependencies).
89
89
  */
90
90
  export const reactiveQueryStream =
@@ -108,30 +108,34 @@ export const reactiveQueryStream =
108
108
 
109
109
  /**
110
110
  * A complete Foldkit subscription entry for a Confect reactive query. The
111
- * leading thunk fixes the `Model` type (TypeScript cannot partially infer
112
- * type arguments), so the `args` extractor's parameter is already typed.
113
- * Pass the result as an entry value to `Subscription.make`:
111
+ * leading thunk fixes the `Model` type (TypeScript cannot partially infer type
112
+ * arguments), so the `args` extractor's parameter is already typed. Pass the
113
+ * result as an entry value to `Subscription.make`:
114
114
  *
115
115
  * ```ts
116
- * import * as Confect from "@confect/foldkit"
117
- * import * as Subscription from "foldkit/subscription"
116
+ * import * as Confect from "@confect/foldkit";
117
+ * import * as Subscription from "foldkit/subscription";
118
118
  *
119
119
  * const subscriptions = Subscription.make<
120
120
  * Model,
121
121
  * Message,
122
122
  * Confect.Client.Client
123
123
  * >()(() => ({
124
- * note: Confect.Subscription.reactiveQuery<Model>()(refs.public.notes.get, {
125
- * args: (model) => Option.map(model.noteId, (noteId) => ({ noteId })),
126
- * onSuccess: (note) => SucceededGetNote({ note }),
127
- * onError: (error) => FailedGetNote({ message: String(error) }),
128
- * }),
129
- * }))
124
+ * note: Confect.Subscription.reactiveQuery<Model>()(
125
+ * refs.public.notes.get,
126
+ * {
127
+ * args: (model) =>
128
+ * Option.map(model.noteId, (noteId) => ({ noteId })),
129
+ * onSuccess: (note) => SucceededGetNote({ note }),
130
+ * onError: (error) => FailedGetNote({ message: String(error) }),
131
+ * },
132
+ * ),
133
+ * }));
130
134
  * ```
131
135
  *
132
136
  * The entry's dependencies are the query args wrapped in `Option`: `None`
133
- * closes the subscription, a change from one `Some` to another unsubscribes
134
- * and resubscribes with the new args, and structurally equal args leave the
137
+ * closes the subscription, a change from one `Some` to another unsubscribes and
138
+ * resubscribes with the new args, and structurally equal args leave the
135
139
  * subscription running (equivalence is derived from the ref's args schema).
136
140
  * Queries without args may omit `args`, leaving the subscription always open.
137
141
  */
@@ -169,18 +173,17 @@ export const reactiveQuery =
169
173
 
170
174
  /**
171
175
  * A complete Foldkit subscription entry that keeps exactly one live reactive
172
- * page subscription in sync with a `PaginatedQuery` machine in the Model.
173
- * The machine state is the single source of truth: navigation and
174
- * split-pinning change the derived args, while `Idle` closes the subscription.
175
- * Pagination ids are allocated here and installed by the first settlement.
176
+ * page subscription in sync with a `PaginatedQuery` machine in the Model. The
177
+ * machine state is the single source of truth: navigation and split-pinning
178
+ * change the derived args, while `Idle` closes the subscription. Pagination ids
179
+ * are allocated here and installed by the first settlement.
176
180
  *
177
- * The leading thunk fixes the `Model` type (TypeScript cannot partially
178
- * infer type arguments), so the `state` extractor's parameter is already
179
- * typed:
181
+ * The leading thunk fixes the `Model` type (TypeScript cannot partially infer
182
+ * type arguments), so the `state` extractor's parameter is already typed:
180
183
  *
181
184
  * ```ts
182
- * import * as Confect from "@confect/foldkit"
183
- * import * as Subscription from "foldkit/subscription"
185
+ * import * as Confect from "@confect/foldkit";
186
+ * import * as Subscription from "foldkit/subscription";
184
187
  *
185
188
  * const subscriptions = Subscription.make<
186
189
  * Model,
@@ -191,13 +194,13 @@ export const reactiveQuery =
191
194
  * state: (model) => model.notes,
192
195
  * onSettled: (settlement) => SettledGetNotesPage({ settlement }),
193
196
  * }),
194
- * }))
197
+ * }));
195
198
  * ```
196
199
  *
197
200
  * Pass the settlement to `PaginatedQuery.settle` in `update`. The request
198
201
  * identity is included in both success and failure Messages, so superseded
199
- * outcomes cannot settle a newer page or pagination session. Query failures
200
- * do not close the Convex subscription; a later result can recover naturally.
202
+ * outcomes cannot settle a newer page or pagination session. Query failures do
203
+ * not close the Convex subscription; a later result can recover naturally.
201
204
  */
202
205
  type DependenciesSchema<Dependencies_> = Schema.Schema<Dependencies_> & {
203
206
  readonly fields: Schema.Struct.Fields;