Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Commit

Permalink
Bump parser version, removed ignore directives
Browse files Browse the repository at this point in the history
  • Loading branch information
msutkowski committed Mar 21, 2021
1 parent c647bfd commit 57a2bee
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 19 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
],
"dependencies": {
"@babel/runtime": "^7.12.5",
"@typescript-eslint/parser": "^4.18.0",
"immer": ">=8.0.0"
},
"peerDependencies": {
Expand Down
24 changes: 5 additions & 19 deletions src/react-hooks/buildHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
// arg did not change, but options probably did, update them
lastPromise.updateSubscriptionOptions({ pollingInterval, refetchOnReconnect, refetchOnFocus });
} else {
if (lastPromise) lastPromise.unsubscribe();
lastPromise?.unsubscribe();
const promise = dispatch(
initiate(stableArg, {
subscriptionOptions: { pollingInterval, refetchOnReconnect, refetchOnFocus },
Expand All @@ -227,7 +227,6 @@ export function buildHooks<Definitions extends EndpointDefinitions>({

useEffect(() => {
return () => {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
promiseRef.current?.unsubscribe();
promiseRef.current = undefined;
};
Expand Down Expand Up @@ -255,42 +254,30 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
const promiseRef = useRef<QueryActionCreatorResult<any>>();
const lastPromise = promiseRef.current;

const optionsRef = useRef<SubscriptionOptions>();

useEffect(() => {
const options = {
refetchOnReconnect,
refetchOnFocus,
pollingInterval,
};
if (optionsRef.current && !shallowEqual(options, optionsRef.current)) {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
if (lastPromise && !shallowEqual(options, lastPromise.subscriptionOptions)) {
lastPromise?.updateSubscriptionOptions(options);
optionsRef.current = options;
}
}, [lastPromise, refetchOnFocus, refetchOnReconnect, pollingInterval]);

useEffect(() => {
return () => {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
promiseRef.current?.unsubscribe();
promiseRef.current = undefined;
optionsRef.current = undefined;
};
}, []);

const trigger = useCallback(
function (args: any) {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
function (arg: any) {
lastPromise?.unsubscribe();

// Set the subscription options on the initial query
if (!optionsRef.current) {
optionsRef.current = { pollingInterval, refetchOnReconnect, refetchOnFocus };
}

promiseRef.current = dispatch(
initiate(args, {
initiate(arg, {
subscriptionOptions: { pollingInterval, refetchOnReconnect, refetchOnFocus },
forceRefetch: true,
})
Expand Down Expand Up @@ -378,7 +365,6 @@ export function buildHooks<Definitions extends EndpointDefinitions>({

useEffect(() => {
return () => {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
promiseRef.current?.unsubscribe();
promiseRef.current = undefined;
};
Expand All @@ -388,7 +374,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
function (args) {
let promise: MutationActionCreatorResult<any>;
batch(() => {
if (promiseRef.current) promiseRef.current.unsubscribe();
promiseRef?.current?.unsubscribe();
promise = dispatch(initiate(args));
promiseRef.current = promise;
setRequestId(promise.requestId);
Expand Down
44 changes: 44 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,24 @@
"@typescript-eslint/typescript-estree" "4.7.0"
debug "^4.1.1"

"@typescript-eslint/parser@^4.18.0":
version "4.18.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.18.0.tgz#a211edb14a69fc5177054bec04c95b185b4dde21"
integrity sha512-W3z5S0ZbecwX3PhJEAnq4mnjK5JJXvXUDBYIYGoweCyWyuvAKfGHvzmpUzgB5L4cRBb+cTu9U/ro66dx7dIimA==
dependencies:
"@typescript-eslint/scope-manager" "4.18.0"
"@typescript-eslint/types" "4.18.0"
"@typescript-eslint/typescript-estree" "4.18.0"
debug "^4.1.1"

"@typescript-eslint/[email protected]":
version "4.18.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.18.0.tgz#d75b55234c35d2ff6ac945758d6d9e53be84a427"
integrity sha512-olX4yN6rvHR2eyFOcb6E4vmhDPsfdMyfQ3qR+oQNkAv8emKKlfxTWUXU5Mqxs2Fwe3Pf1BoPvrwZtwngxDzYzQ==
dependencies:
"@typescript-eslint/types" "4.18.0"
"@typescript-eslint/visitor-keys" "4.18.0"

"@typescript-eslint/[email protected]":
version "4.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.7.0.tgz#2115526085fb72723ccdc1eeae75dec7126220ed"
Expand All @@ -1579,6 +1597,11 @@
"@typescript-eslint/types" "4.7.0"
"@typescript-eslint/visitor-keys" "4.7.0"

"@typescript-eslint/[email protected]":
version "4.18.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.18.0.tgz#bebe323f81f2a7e2e320fac9415e60856267584a"
integrity sha512-/BRociARpj5E+9yQ7cwCF/SNOWwXJ3qhjurMuK2hIFUbr9vTuDeu476Zpu+ptxY2kSxUHDGLLKy+qGq2sOg37A==

"@typescript-eslint/[email protected]":
version "4.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.7.0.tgz#5e95ef5c740f43d942542b35811f87b62fccca69"
Expand All @@ -1597,6 +1620,19 @@
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/[email protected]":
version "4.18.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.18.0.tgz#756d3e61da8c16ab99185532c44872f4cd5538cb"
integrity sha512-wt4xvF6vvJI7epz+rEqxmoNQ4ZADArGQO9gDU+cM0U5fdVv7N+IAuVoVAoZSOZxzGHBfvE3XQMLdy+scsqFfeg==
dependencies:
"@typescript-eslint/types" "4.18.0"
"@typescript-eslint/visitor-keys" "4.18.0"
debug "^4.1.1"
globby "^11.0.1"
is-glob "^4.0.1"
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/[email protected]":
version "4.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.7.0.tgz#539531167f05ba20eb0b6785567076679e29d393"
Expand All @@ -1611,6 +1647,14 @@
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/[email protected]":
version "4.18.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.18.0.tgz#4e6fe2a175ee33418318a029610845a81e2ff7b6"
integrity sha512-Q9t90JCvfYaN0OfFUgaLqByOfz8yPeTAdotn/XYNm5q9eHax90gzdb+RJ6E9T5s97Kv/UHWKERTmqA0jTKAEHw==
dependencies:
"@typescript-eslint/types" "4.18.0"
eslint-visitor-keys "^2.0.0"

"@typescript-eslint/[email protected]":
version "4.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.7.0.tgz#6783824f22acfc49e754970ed21b88ac03b80e6f"
Expand Down

0 comments on commit 57a2bee

Please sign in to comment.