Skip to content

Commit

Permalink
chore: update deps
Browse files Browse the repository at this point in the history
chore: update `saga-query` changes
  • Loading branch information
neurosnap committed Sep 15, 2023
1 parent fec6a2d commit e0dffb4
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 20 deletions.
36 changes: 36 additions & 0 deletions deno.lock

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

8 changes: 4 additions & 4 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type {
Stream,
Subscription,
Task,
} from "https://deno.land/x/[email protected].13/mod.ts";
} from "https://deno.land/x/[email protected].14/mod.ts";
export {
action,
createChannel,
Expand All @@ -27,7 +27,7 @@ export {
spawn,
suspend,
useAbortSignal,
} from "https://deno.land/x/[email protected].13/mod.ts";
} from "https://deno.land/x/[email protected].14/mod.ts";

import React from "https://esm.sh/[email protected]?pin=v122";
export { React };
Expand Down Expand Up @@ -64,10 +64,10 @@ export {
export type {
MapEntity,
PatchEntity,
} from "https://esm.sh/[email protected].1?pin=v122";
} from "https://esm.sh/[email protected].2?pin=v122";
export {
createLoaderTable,
createReducerMap,
createTable,
mapReducers,
} from "https://esm.sh/[email protected].1?pin=v122";
} from "https://esm.sh/[email protected].2?pin=v122";
8 changes: 4 additions & 4 deletions npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ async function main() {
},
],
mappings: {
"https://deno.land/x/[email protected].13/mod.ts": {
"https://deno.land/x/[email protected].14/mod.ts": {
name: "effection",
version: "3.0.0-alpha.13",
version: "3.0.0-alpha.14",
},
"https://esm.sh/[email protected]?pin=v122": {
name: "react",
Expand All @@ -51,9 +51,9 @@ async function main() {
name: "reselect",
version: "^4.1.8",
},
"https://esm.sh/[email protected].1?pin=v122": {
"https://esm.sh/[email protected].2?pin=v122": {
name: "robodux",
version: "^15.0.1",
version: "^15.0.2",
},
"https://esm.sh/[email protected]?pin=v122": {
name: "redux",
Expand Down
3 changes: 2 additions & 1 deletion query/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
takeEvery,
} from "../store/mod.ts";

import { fetcher, fetchRetry } from "./fetch.ts";
import { fetcher, fetchRetry, headersMdw } from "./fetch.ts";
import { createApi } from "./api.ts";
import { requestMonitor } from "./middleware.ts";

Expand Down Expand Up @@ -45,6 +45,7 @@ it(
api.use(requestMonitor());
api.use(storeMdw(schema.db));
api.use(api.routes());
api.use(headersMdw);
api.use(fetcher({ baseUrl }));

const actual: any[] = [];
Expand Down
1 change: 0 additions & 1 deletion query/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ export function fetcher<CurCtx extends FetchJsonCtx = FetchJsonCtx>(
} = { baseUrl: "" },
) {
return compose<CurCtx>([
headersMdw,
apiUrlMdw(baseUrl),
payloadMdw,
fetchMdw,
Expand Down
3 changes: 1 addition & 2 deletions query/middleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,13 @@ it(tests, "overriding default loader behavior", () => {
`/users`,
{ supervisor: takeEvery },
function* (ctx: ApiCtx<unknown, { users: User[] }>, next) {
const id = ctx.name;
yield* next();

if (!ctx.json.ok) {
return;
}
const { data } = ctx.json;
ctx.loader = { id, message: "yes", meta: { wow: true } };
ctx.loader = { message: "yes", meta: { wow: true } };
yield* updateStore((state) => {
data.users.forEach((u) => {
state.users[u.id] = u;
Expand Down
13 changes: 6 additions & 7 deletions query/react.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { LoaderState, QueryState } from "../types.ts";
import { React, useDispatch, useSelector } from "../deps.ts";
const { useState, useEffect } = React;
const { useEffect, useRef } = React;

// TODO: remove store deps
import { selectDataById, selectLoaderById } from "../redux/mod.ts";
Expand Down Expand Up @@ -201,15 +201,14 @@ export function useCache<D = any, A extends SagaAction = SagaAction>(
* ```
*/
export function useLoaderSuccess(
cur: Pick<LoaderState, "isLoading" | "isSuccess">,
cur: Pick<LoaderState, "status">,
success: () => any,
) {
const [prev, setPrev] = useState(cur);
const prev = useRef(cur);
useEffect(() => {
const curSuccess = !cur.isLoading && cur.isSuccess;
if (prev.isLoading && curSuccess) {
if (prev.current.status !== "success" && cur.status === "success") {
success();
}
setPrev(cur);
}, [cur.isSuccess, cur.isLoading]);
prev.current = cur;
}, [cur.status]);
}
2 changes: 1 addition & 1 deletion query/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface FetchJsonCtx<P = any, ApiSuccess = any, ApiError = any>
export interface ApiCtx<Payload = any, ApiSuccess = any, ApiError = any>
extends FetchJsonCtx<Payload, ApiSuccess, ApiError> {
actions: Action[];
loader: LoaderPayload<any> | null;
loader: Omit<LoaderPayload<any>, "id"> | null;
cache: boolean;
cacheData: any;
}
Expand Down

0 comments on commit e0dffb4

Please sign in to comment.