()
| 1125 | CursorSchema, |
| 1126 | Error |
| 1127 | > = (): any => |
| 1128 | ( |
| 1129 | name: string, |
| 1130 | options: { |
| 1131 | readonly args?: Schema.Top | Schema.Struct.Fields | undefined |
| 1132 | readonly page: Schema.Top |
| 1133 | readonly items: (page: any) => ReadonlyArray<any> |
| 1134 | readonly key: (item: any) => string |
| 1135 | readonly error?: Schema.Top | undefined |
| 1136 | readonly cursor: Schema.Top |
| 1137 | readonly next: (lastPage: any, allPages: any) => Option.Option<any> |
| 1138 | readonly staleTime: Duration.Input |
| 1139 | readonly idleTimeToLive?: Duration.Input | undefined |
| 1140 | readonly refetchInterval?: RefetchInterval<any, any, any> | undefined |
| 1141 | readonly tags?: ReadonlyArray<Tag> | undefined |
| 1142 | readonly persist?: boolean | undefined |
| 1143 | readonly reactivityKeys?: ((args: any) => Reactivity.KeysInput) | undefined |
| 1144 | readonly server?: boolean | undefined |
| 1145 | } |
| 1146 | ): any => { |
| 1147 | const def = makeDef( |
| 1148 | name, |
| 1149 | { ...options, success: Schema.Array(options.page) }, |
| 1150 | makeListDef({ |
| 1151 | items: options.items, |
| 1152 | key: options.key, |
| 1153 | next: options.next, |
| 1154 | cursor: options.cursor |
| 1155 | }) |
| 1156 | ) |
| 1157 | const QueryService = queryClass(def) |
| 1158 | return class extends QueryService { |
| 1159 | static readonly [InfiniteTypeId]: any = InfiniteTypeId |
| 1160 | static loadMore(args: unknown) { |
| 1161 | return withCache((cache, context) => |
| 1162 | Effect.callback<any, any>((resume) => { |
| 1163 | const cancel = cache.loadMore( |
| 1164 | def, |
| 1165 | args, |
| 1166 | fetcherOf(context, QueryService), |
| 1167 | resume |
| 1168 | ) |
| 1169 | return Effect.sync(cancel) |
| 1170 | }) |
| 1171 | ) |
| 1172 | } |
| 1173 | static reset(args: unknown) { |
| 1174 | return withCache((cache) => Effect.sync(() => cache.reset(def, args))) |
| 1175 | } |
| 1176 | static items(pages: ReadonlyArray<unknown>) { |
| 1177 | return infiniteItems(def, pages) |
| 1178 | } |
| 1179 | static override patch(args: unknown, f: (page: any, index: number) => any) { |
| 1180 | return patchOne( |
| 1181 | QueryService, |
| 1182 | args, |
| 1183 | (pages: ReadonlyArray<unknown>) => pages.map((page, i) => f(page, i)) |
| 1184 | ) |
nothing calls this directly
no test coverage detected