-
Notifications
You must be signed in to change notification settings - Fork 53
feat(cmf): add redux-saga integration at component level #1055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
791593c
feat(cmf): add redux-saga integration at component level
jmfrancois 9f15f4e
chore cleanum
jmfrancois 4adc1d9
test(ci): update code style outputs
28cd8a9
test(ci): prettier
7fe7106
chore: refactor follow review
jmfrancois 0a10074
Merge branch 'jmfrancois/feat/cmf-add-saga-integration' of github.com…
jmfrancois 5a8e49d
test(ci): update code style outputs
ea9ab3f
test: add some
jmfrancois 7f07eac
test(ci): update code style outputs
2b4d358
Merge branch 'master' into jmfrancois/feat/cmf-add-saga-integration
talend-glorieux f431807
test(ci): update code style outputs
9f6865e
Merge branch 'master' into jmfrancois/feat/cmf-add-saga-integration
jmfrancois 7250763
test(ci): update code style outputs [skip ci]
b122a78
test: add some + doc
jmfrancois 609a326
test(ci): prettier [skip ci]
3dbed53
chore: wip
jmfrancois c7a9186
Merge branch 'master' into jmfrancois/feat/cmf-add-saga-integration
jmfrancois ad0b0ce
Merge branch 'jmfrancois/feat/cmf-add-saga-integration' of github.com…
jmfrancois e4c9fa9
test(ci): update code style outputs
5a42f82
test(ci): prettier
8728364
test: move them and fix them all
jmfrancois 3b64347
Merge branch 'jmfrancois/feat/cmf-add-saga-integration' of github.com…
jmfrancois f1ae245
test(ci): update code style outputs
44b11c8
add comments here
romainseb 6e407ea
Merge branch 'master' into jmfrancois/feat/cmf-add-saga-integration
acateland ad86beb
chore: follow review
jmfrancois 1b13f4a
Merge branch 'jmfrancois/feat/cmf-add-saga-integration' of github.com…
jmfrancois f345662
Merge branch 'master' into jmfrancois/feat/cmf-add-saga-integration
jmfrancois a4e97c4
Merge branch 'master' into jmfrancois/feat/cmf-add-saga-integration
jmfrancois 8ee46bc
fix: test
jmfrancois 1176be7
doc: update
jmfrancois 7647972
Merge branch 'jmfrancois/feat/cmf-add-saga-integration' of github.com…
jmfrancois File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { | ||
| start, | ||
| stop, | ||
| } from '../../src/actions/saga'; | ||
| import CONST from '../../src/constant'; | ||
|
|
||
| describe('actions.saga', () => { | ||
| it('start should return action object with DID_MOUNT_SAGA_START', () => { | ||
| const event = { type: 'DID_MOUNT' }; | ||
| const data = { saga: 'mySaga' }; | ||
| expect(start(event, data)).toEqual({ | ||
| type: CONST.DID_MOUNT_SAGA_START, | ||
| saga: data.saga, | ||
| event, | ||
| }); | ||
| }); | ||
| it('start should return action object with WILL_UNMUNT_SAGA_STOP', () => { | ||
| const event = { type: 'WILL_UNMOUNT' }; | ||
| const data = { saga: 'mySaga' }; | ||
| expect(stop(event, data)).toEqual({ | ||
| type: `${CONST.WILL_UNMOUNT_SAGA_STOP}_${data.saga}`, | ||
| event, | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { fork, take, takeEvery, cancel } from 'redux-saga/effects'; | ||
| import { createMockTask } from 'redux-saga/utils'; | ||
| import registry from '../../src/registry'; | ||
| import { onSagaStart, handle } from '../../src/sagas/component'; | ||
| import CONST from '../../src/constant'; | ||
|
|
||
| describe('sagas.component', () => { | ||
| it('should onSagaStart fork action.saga and wait for unmount to cancel', () => { | ||
| // given | ||
| const testAction = { type: 'TEST', saga: 'my-saga' }; | ||
| function* saga() {} | ||
| const reg = registry.getRegistry(); | ||
| reg['SAGA:my-saga'] = saga; | ||
| const task = createMockTask(); | ||
| // when | ||
| const gen = onSagaStart(testAction); | ||
|
|
||
| // then | ||
| expect(gen.next().value).toEqual(fork(saga)); | ||
| expect(gen.next(task).value).toEqual(take(`${CONST.WILL_UNMOUNT_SAGA_STOP}_my-saga`)); | ||
| expect(gen.next().value).toEqual(cancel(task)); | ||
| }); | ||
| it('should handle takeEvery didmount', () => { | ||
| // given | ||
| const gen = handle(); | ||
| const didMountAction = { type: CONST.DID_MOUNT_SAGA_START }; | ||
|
|
||
| // then | ||
| expect(gen.next(didMountAction).value).toEqual( | ||
| takeEvery(CONST.DID_MOUNT_SAGA_START, onSagaStart) | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import CONST from '../constant'; | ||
|
|
||
| export function start(event = {}, data) { | ||
| return { | ||
| type: CONST.DID_MOUNT_SAGA_START, | ||
| saga: data.saga, | ||
| event, | ||
| }; | ||
| } | ||
|
|
||
| export function stop(event, data) { | ||
| return { | ||
| type: `${CONST.WILL_UNMOUNT_SAGA_STOP}_${data.saga}`, | ||
| event, | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use invariant instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one is for a deprecation warning, invariant throw an error, so it block the app in dev.