Skip to content

Commit

Permalink
Merge pull request #3212 from marmelab/upgrade-redux-saga
Browse files Browse the repository at this point in the history
[RFR] Upgrade redux saga
  • Loading branch information
fzaninotto committed May 11, 2019
2 parents fe5acd7 + ca524dd commit 1e7c41e
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 29 deletions.
2 changes: 1 addition & 1 deletion examples/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"react-scripts": "^3.0.0",
"recompose": "~0.26.0",
"redux-form": "~8.2.0",
"redux-saga": "~0.16.0"
"redux-saga": "^1.0.0"
},
"scripts": {
"start": "react-scripts start",
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/layout/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import CardActions from '@material-ui/core/CardActions';
import CircularProgress from '@material-ui/core/CircularProgress';
import TextField from '@material-ui/core/TextField';
import { createMuiTheme, withStyles } from '@material-ui/core/styles';
import { ThemeProvider } from '@material-ui/core/styles';
import { ThemeProvider } from '@material-ui/styles';
import LockIcon from '@material-ui/icons/Lock';

import { Notification, useTranslate, translate, userLogin } from 'react-admin';
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import Configuration from './configuration/Configuration';
import Segments from './segments/Segments';

export default [
<Route exact path="/configuration" component={Configuration} />,
<Route exact path="/segments" component={Segments} />,
<Route exact path="/configuration" render={() => <Configuration />} />,
<Route exact path="/segments" render={() => <Segments />} />,
];
3 changes: 2 additions & 1 deletion packages/ra-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"watch": "rimraf ./lib && tsc --watch"
},
"devDependencies": {
"@redux-saga/testing-utils": "^1.0.2",
"@types/history": "^4.7.2",
"@types/node-polyglot": "^0.4.31",
"@types/react-router": "^4.4.4",
Expand Down Expand Up @@ -64,7 +65,7 @@
"recompose": "~0.26.0",
"redux": "^3.7.2 || ^4.0.0",
"redux-form": "~8.2.0",
"redux-saga": "~0.16.0",
"redux-saga": "^1.0.0",
"reselect": "~3.0.0"
}
}
7 changes: 3 additions & 4 deletions packages/ra-core/src/sideEffect/accumulate.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import expect from 'expect';
import { delay } from 'redux-saga';
import { call, cancel, fork, put } from 'redux-saga/effects';
import { createMockTask } from 'redux-saga/utils';
import { call, cancel, delay, fork, put } from 'redux-saga/effects';
import { createMockTask } from '@redux-saga/testing-utils';

import { accumulateFactory, finalizeFactory } from './accumulate';
import { crudGetMany } from '../actions';
Expand Down Expand Up @@ -60,7 +59,7 @@ describe('accumulate saga', () => {
crudGetMany
);

expect(saga.next().value).toEqual(call(delay, 50));
expect(saga.next().value).toEqual(delay(50));

expect(saga.next().value).toEqual(
put(crudGetMany('posts', [1, 2]))
Expand Down
5 changes: 2 additions & 3 deletions packages/ra-core/src/sideEffect/accumulate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { delay } from 'redux-saga';
import { call, cancel, fork, put, takeEvery } from 'redux-saga/effects';
import { call, cancel, delay, fork, put, takeEvery } from 'redux-saga/effects';

/**
* Distinct reducer on ids
Expand Down Expand Up @@ -28,7 +27,7 @@ export const finalizeFactory = (tasks, accumulations) =>
*/
function* finalize(key, actionCreator) {
// combined with cancel(), this debounces the calls
yield call(delay, 50);
yield delay(50);

// Get the latest accumulated value for the provided key
const accumulatedValue = accumulations[key];
Expand Down
18 changes: 15 additions & 3 deletions packages/ra-core/src/sideEffect/undo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import expect from 'expect';
import { put } from 'redux-saga/effects';
import { put, race, take } from 'redux-saga/effects';

import { showNotification } from '../actions/notificationActions';
import {
UNDO,
COMPLETE,
startOptimisticMode,
stopOptimisticMode,
} from '../actions/undoActions';
Expand Down Expand Up @@ -46,7 +48,12 @@ describe('undo saga', () => {
);
});
it('should fork the race', () => {
expect(generator.next().value).toHaveProperty('RACE');
expect(generator.next().value).toEqual(
race({
undo: take(UNDO),
complete: take(COMPLETE),
})
);
});
it('should stop the optimistic mode', () => {
expect(generator.next({ undo: true }).value).toEqual(
Expand Down Expand Up @@ -85,7 +92,12 @@ describe('undo saga', () => {
);
});
it('should fork the race', () => {
expect(generator.next().value).toHaveProperty('RACE');
expect(generator.next().value).toEqual(
race({
undo: take(UNDO),
complete: take(COMPLETE),
})
);
});
it('should stop the optimistic mode', () => {
expect(generator.next({ complete: true }).value).toEqual(
Expand Down
4 changes: 2 additions & 2 deletions packages/ra-realtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
"ra-core": "^2.5.0",
"react-admin": "^2.5.3",
"react-router": "^4.2.0",
"redux-saga": "~0.16.0"
"redux-saga": "^1.0.0"
},
"devDependencies": {
"connected-react-router": "^6.4.0",
"cross-env": "^5.2.0",
"react-router": "^4.2.0",
"redux-saga": "~0.16.0",
"redux-saga": "^1.0.0",
"rimraf": "^2.6.3"
}
}
97 changes: 85 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,58 @@
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.0.tgz#50c1e2260ac0ed9439a181de3725a0168d59c48a"
integrity sha512-LAQ1d4OPfSJ/BMbI2DuizmYrrkD9JMaTdi2hQTlI53lQ4kRQPyZQRS4CYQ7O66bnBBnP/oYdRxbk++X0xuFU6A==

"@redux-saga/core@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@redux-saga/core/-/core-1.0.2.tgz#4336a5bb4253e5ca69681c25a863fbbc03ea6d88"
integrity sha512-AsJYcpuYfM1cmxJvfhXs9HAFSZVEG17TMsLPlXH7+Hq5a5ZP4GqcbtijEmS2AC7NR5lLJHy8csxpqz22PeW5dw==
dependencies:
"@babel/runtime" "^7.0.0"
"@redux-saga/deferred" "^1.0.1"
"@redux-saga/delay-p" "^1.0.1"
"@redux-saga/is" "^1.0.2"
"@redux-saga/symbols" "^1.0.1"
"@redux-saga/types" "^1.0.2"
redux ">=0.10 <5"
typescript-tuple "^2.1.0"

"@redux-saga/deferred@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@redux-saga/deferred/-/deferred-1.0.1.tgz#c895445e486bded90acf0b873b4e978fbfe458c2"
integrity sha512-+gW5xQ93QXOOmRLAmX8x2Hx1HpbTG6CM6+HcdTSbJovh4uMWaGyeDECnqXSt8QqA/ja3s2nqYXLqXFKepIQ1hw==

"@redux-saga/delay-p@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@redux-saga/delay-p/-/delay-p-1.0.1.tgz#d69fc6103c7509ae80faa144ea17bbc69e51e029"
integrity sha512-0SnNDyDLUyB4NThtptAwiprNOnbCNhoed/Rp5JwS7SB+a/AdWynVgg/E6BmjsggLFNr07KW0bzn05tsPRBuU7Q==
dependencies:
"@redux-saga/symbols" "^1.0.1"

"@redux-saga/is@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@redux-saga/is/-/is-1.0.2.tgz#7f4be014c97061898d7efb11d6c9de31e943ed38"
integrity sha512-WnaUOwYvPK2waWjzebT4uhL8zY76XNkzzpJ2EQJe8bN1tByvAjvT7MuJZTSshOhdHL5PsRO0MsH224XIXBJidQ==
dependencies:
"@redux-saga/symbols" "^1.0.1"
"@redux-saga/types" "^1.0.2"

"@redux-saga/symbols@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@redux-saga/symbols/-/symbols-1.0.1.tgz#46512ae1275f88df061c42168d0f600ddb170c1e"
integrity sha512-akKkzcVnb1RzJaZV2LQFbi51abvdICMuAKwwLoCjjxLbLAGIw9EJxk5ucNnWSSCEsoEQMeol5tkAcK+Xzuv1Bg==

"@redux-saga/testing-utils@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@redux-saga/testing-utils/-/testing-utils-1.0.2.tgz#e1f6dcbae728e45f7c8d7c03cf763b03abb9c32e"
integrity sha512-pywf97heIqtapX/Uk4vVFXnpfars1Yh5xJu3mYffZfyMupziAmNe5DW/2HNZiWFnWLyWI9/3ykTo3+cfEGoNcg==
dependencies:
"@redux-saga/symbols" "^1.0.1"
"@redux-saga/types" "^1.0.2"

"@redux-saga/types@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@redux-saga/types/-/types-1.0.2.tgz#1d94f02800b094753f9271c206a26c2a06ca14ee"
integrity sha512-8/qcMh15507AnXJ3lBeuhsdFwnWQqnp68EpUuHlYPixJ5vjVmls7/Jq48cnUlrZI8Jd9U1jkhfCl0gaT5KMgVw==

"@sheerun/mutationobserver-shim@^0.3.2":
version "0.3.2"
resolved "https://registry.yarnpkg.com/@sheerun/mutationobserver-shim/-/mutationobserver-shim-0.3.2.tgz#8013f2af54a2b7d735f71560ff360d3a8176a87b"
Expand Down Expand Up @@ -14241,10 +14293,20 @@ redux-form@~8.2.0:
react-is "^16.7.0"
react-lifecycles-compat "^3.0.4"

redux-saga@~0.16.0:
version "0.16.0"
resolved "https://registry.yarnpkg.com/redux-saga/-/redux-saga-0.16.0.tgz#0a231db0a1489301dd980f6f2f88d8ced418f724"
integrity sha1-CiMdsKFIkwHdmA9vL4jYztQY9yQ=
redux-saga@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/redux-saga/-/redux-saga-1.0.2.tgz#0599703f975438f1b2f9d2b9a965ec58f0fdfcd7"
integrity sha512-dHV256by3eF2AnBPx1l3HqazQFkErZ82HDXgh4jSRpT72OrX31wyg8DA1q8+0HvENRfJAyhT/4qT5yH/vVqFfw==
dependencies:
"@redux-saga/core" "^1.0.2"

"redux@>=0.10 <5", "redux@^3.6.0 || ^4.0.0", "redux@^3.7.2 || ^4.0.0":
version "4.0.1"
resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.1.tgz#436cae6cc40fbe4727689d7c8fae44808f1bfef5"
integrity sha512-R7bAtSkk7nY6O/OYMVR9RiBI+XghjF9rlbl5806HJbQph0LJVHZrU5oaO4q70eUKiqMRqm4y07KLTlMZ2BlVmg==
dependencies:
loose-envify "^1.4.0"
symbol-observable "^1.2.0"

redux@^3.4.0:
version "3.7.2"
Expand All @@ -14256,14 +14318,6 @@ redux@^3.4.0:
loose-envify "^1.1.0"
symbol-observable "^1.0.3"

"redux@^3.6.0 || ^4.0.0", "redux@^3.7.2 || ^4.0.0":
version "4.0.1"
resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.1.tgz#436cae6cc40fbe4727689d7c8fae44808f1bfef5"
integrity sha512-R7bAtSkk7nY6O/OYMVR9RiBI+XghjF9rlbl5806HJbQph0LJVHZrU5oaO4q70eUKiqMRqm4y07KLTlMZ2BlVmg==
dependencies:
loose-envify "^1.4.0"
symbol-observable "^1.2.0"

redux@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.0.tgz#aa698a92b729315d22b34a0553d7e6533555cc03"
Expand Down Expand Up @@ -16206,6 +16260,25 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typescript-compare@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/typescript-compare/-/typescript-compare-0.0.2.tgz#7ee40a400a406c2ea0a7e551efd3309021d5f425"
integrity sha512-8ja4j7pMHkfLJQO2/8tut7ub+J3Lw2S3061eJLFQcvs3tsmJKp8KG5NtpLn7KcY2w08edF74BSVN7qJS0U6oHA==
dependencies:
typescript-logic "^0.0.0"

typescript-logic@^0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/typescript-logic/-/typescript-logic-0.0.0.tgz#66ebd82a2548f2b444a43667bec120b496890196"
integrity sha512-zXFars5LUkI3zP492ls0VskH3TtdeHCqu0i7/duGt60i5IGPIpAHE/DWo5FqJ6EjQ15YKXrt+AETjv60Dat34Q==

typescript-tuple@^2.1.0:
version "2.2.1"
resolved "https://registry.yarnpkg.com/typescript-tuple/-/typescript-tuple-2.2.1.tgz#7d9813fb4b355f69ac55032e0363e8bb0f04dad2"
integrity sha512-Zcr0lbt8z5ZdEzERHAMAniTiIKerFCMgd7yjq1fPnDJ43et/k9twIFQMUYff9k5oXcsQ0WpvFcgzK2ZKASoW6Q==
dependencies:
typescript-compare "^0.0.2"

typescript@^3.4.5:
version "3.4.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.4.5.tgz#2d2618d10bb566572b8d7aad5180d84257d70a99"
Expand Down

0 comments on commit 1e7c41e

Please sign in to comment.