Skip to content

Commit

Permalink
chore: Updates dev dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlplusb committed Sep 15, 2022
1 parent c63555c commit 67b9aaf
Show file tree
Hide file tree
Showing 7 changed files with 1,066 additions and 1,581 deletions.
18 changes: 9 additions & 9 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"index.js": {
"bundled": 51086,
"minified": 21465,
"gzipped": 6456,
"bundled": 51221,
"minified": 21486,
"gzipped": 6458,
"treeshaked": {
"rollup": {
"code": 135,
Expand All @@ -14,14 +14,14 @@
}
},
"index.cjs.js": {
"bundled": 52462,
"minified": 22650,
"gzipped": 6627
"bundled": 52597,
"minified": 22671,
"gzipped": 6630
},
"index.iife.js": {
"bundled": 55365,
"minified": 18393,
"gzipped": 6023
"bundled": 55510,
"minified": 18414,
"gzipped": 6030
},
"ie11.js": {
"bundled": 102,
Expand Down
25 changes: 15 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"devDependencies": {
"@babel/cli": "^7.17.0",
"@babel/core": "^7.17.2",
"@babel/eslint-parser": "^7.19.1",
"@babel/node": "^7.16.8",
"@babel/plugin-external-helpers": "^7.16.7",
"@babel/plugin-proposal-object-rest-spread": "^7.16.7",
Expand All @@ -76,23 +77,23 @@
"@types/react-redux": "^7.1.22",
"app-root-dir": "^1.0.2",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.3",
"babel-jest": "^27.5.1",
"babel-jest": "^29.0.3",
"codecov": "^3.8.3",
"eslint": "^8.8.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-markdown": "^2.2.0",
"eslint-plugin-markdown": "^3.0.0",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"husky": "5.1.3",
"jest": "^27.5.1",
"lint-staged": "^11.2.3",
"pinst": "^2.1.6",
"jest": "^29.0.3",
"jest-environment-jsdom": "^29.0.3",
"lint-staged": "^13.0.3",
"pinst": "^3.0.0",
"prettier": "^2.5.1",
"prettier-eslint": "^13.0.0",
"prettier-eslint": "^15.0.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.6",
Expand All @@ -104,7 +105,7 @@
"rollup-plugin-size-snapshot": "^0.12.0",
"shallowequal": "^1.1.0",
"title-case": "^3.0.3",
"typescript": "4.5.5",
"typescript": "4.8.3",
"typings-tester": "^0.3.2"
},
"jest": {
Expand All @@ -124,7 +125,11 @@
]
},
"eslintConfig": {
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"parserOptions": {
"requireConfigFile": false,
"ecmaVersion": "latest"
},
"root": true,
"env": {
"browser": true,
Expand Down
26 changes: 15 additions & 11 deletions src/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,20 @@ const logEffectEventListenerError = (type, err) => {
console.log(err);
};

const handleEventDispatchErrors = (type, dispatcher) => (...args) => {
try {
const result = dispatcher(...args);
if (isPromise(result)) {
result.catch((err) => {
logEffectEventListenerError(type, err);
});
const handleEventDispatchErrors =
(type, dispatcher) =>
(...args) => {
try {
const result = dispatcher(...args);
if (isPromise(result)) {
result.catch((err) => {
logEffectEventListenerError(type, err);
});
}
} catch (err) {
logEffectEventListenerError(type, err);
}
} catch (err) {
logEffectEventListenerError(type, err);
}
};
};

export function createEffectActionsCreator(def, _r, effectHandler) {
const actionCreator = (previousDependencies, nextDependencies, action) => {
Expand Down Expand Up @@ -150,6 +152,8 @@ export function createEffectActionsCreator(def, _r, effectHandler) {
} catch (err) {
logEffectError(err);
}

return undefined;
};

actionCreator.type = def.meta.type;
Expand Down
31 changes: 18 additions & 13 deletions src/persistence.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function createStorageWrapper(storage, transformers = []) {
storage = sessionStorage();
} else {
if (process.env.NODE_ENV === 'development') {
// eslint-disable-next-line no-console
console.warn(`Invalid storage provider`);
}
storage = noopStorage;
Expand Down Expand Up @@ -148,8 +149,10 @@ function createPersistenceClearer(persistKey, _r) {
return Promise.resolve();
}
return pSeries(
_r._i._persistenceConfig.map(({ path, config }) => () =>
Promise.resolve(config.storage.removeItem(persistKey(path))),
_r._i._persistenceConfig.map(
({ path, config }) =>
() =>
Promise.resolve(config.storage.removeItem(persistKey(path))),
),
);
};
Expand Down Expand Up @@ -232,17 +235,19 @@ export function createPersistor(persistKey, _r) {
}

export function createPersistMiddleware(persistor, _r) {
return ({ getState }) => (next) => (action) => {
const state = next(action);
if (
action &&
action.type !== '@action.ePRS' &&
_r._i._persistenceConfig.length > 0
) {
persistor.persist(getState());
}
return state;
};
return ({ getState }) =>
(next) =>
(action) => {
const state = next(action);
if (
action &&
action.type !== '@action.ePRS' &&
_r._i._persistenceConfig.length > 0
) {
persistor.persist(getState());
}
return state;
};
}

export function rehydrateStateFromPersistIfNeeded(
Expand Down
24 changes: 13 additions & 11 deletions src/thunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,20 @@ const logThunkEventListenerError = (type, err) => {
console.log(err);
};

const handleEventDispatchErrors = (type, dispatcher) => (...args) => {
try {
const result = dispatcher(...args);
if (isPromise(result)) {
result.catch((err) => {
logThunkEventListenerError(type, err);
});
const handleEventDispatchErrors =
(type, dispatcher) =>
(...args) => {
try {
const result = dispatcher(...args);
if (isPromise(result)) {
result.catch((err) => {
logThunkEventListenerError(type, err);
});
}
} catch (err) {
logThunkEventListenerError(type, err);
}
} catch (err) {
logThunkEventListenerError(type, err);
}
};
};

export function createThunkActionsCreator(def, _r) {
const actionCreator = (payload) => {
Expand Down
27 changes: 14 additions & 13 deletions src/use-local-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { useEffect, useRef, useState } from 'react';
import { useMemoOne } from './lib';
import { createStore } from './create-store';

export function useLocalStore(modelCreator, dependencies = [], configCreator) {
export function useLocalStore(
modelCreator,
dependencies = [],
configCreator = null,
) {
const storeRef = useRef();

const configRef = useRef();
Expand All @@ -22,18 +26,15 @@ export function useLocalStore(modelCreator, dependencies = [], configCreator) {

const [currentState, setCurrentState] = useState(() => store.getState());

useEffect(
() => {
setCurrentState(store.getState());
store.subscribe(() => {
const nextState = store.getState();
if (currentState !== nextState) {
setCurrentState(nextState);
}
});
},
[store],
);
useEffect(() => {
setCurrentState(store.getState());
store.subscribe(() => {
const nextState = store.getState();
if (currentState !== nextState) {
setCurrentState(nextState);
}
});
}, [store]);

return [currentState, store.getActions(), store];
}
Loading

0 comments on commit 67b9aaf

Please sign in to comment.