-
Notifications
You must be signed in to change notification settings - Fork 55
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
feat(cmf): add redux-saga integration at component level #1055
Conversation
…:Talend/ui into jmfrancois/feat/cmf-add-saga-integration
…:Talend/ui into jmfrancois/feat/cmf-add-saga-integration
…:Talend/ui into jmfrancois/feat/cmf-add-saga-integration
packages/cmf/src/sagas/collection.js
Outdated
export function* waitFor(id, interval = 10) { | ||
// eslint-disable-next-line no-constant-condition | ||
while (true) { | ||
const collection = yield select(state => state.cmf.collections.get(id)); |
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.
Make a dediacted function instead of a anonymous one would be better no ?
By the way i think that you didn't do the TU here.
if (!saga) { | ||
invariant(process.env.NODE_ENV !== 'production', `The saga ${action.saga} is not registred`); | ||
} else { | ||
const task = yield fork(saga); |
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.
It might be a dumb question, but do we really always want to do a fork of the saga ?
@@ -5,7 +5,7 @@ | |||
The react/require-extension rule is deprecated. Please use the import/extensions rule from eslint-plugin-import instead. | |||
|
|||
/home/travis/build/Talend/ui/packages/cmf/src/cmfConnect.js | |||
151:4 warning Unexpected console statement no-console | |||
152:4 warning Unexpected console statement no-console |
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.
packages/cmf/src/api.js
Outdated
@@ -38,5 +44,7 @@ export default { | |||
expression, | |||
route, | |||
registry, | |||
registerInternals, | |||
sagas, |
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.
sagas & saga feel me strange, could be ambiguous
could one of those ( sagas ) be renamed or moved maybe ?
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.
merged into one
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.
Just to put the PR on hold, giving me time to work out some docs, and maybe change the implementation so testing saga using the putActionCreator
will be consitent with other redux-saga api
* @param {string} id of the collection to wait for | ||
* @param {number} interval in ms | ||
*/ | ||
export function* waitFor(id, interval = 10) { |
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.
would rename it to waitForCollectionAvailable
so it is not mistaken with some low level saga helper like delay(ms, [val])
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.
it's already in a 'collection' module :/
…:Talend/ui into jmfrancois/feat/cmf-add-saga-integration
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.
My updated doc for this will come in another PR
…:Talend/ui into jmfrancois/feat/cmf-add-saga-integration
What is the problem this PR is trying to solve?
Today we have the saga router, so you can start / stop saga on each route.
You can't do that at component level
What is the chosen solution to this problem?
If your component is cmfConnected you can pass a props.saga (string) which will be start & stop by the saga
api.sagas.component.handle
that you should register in your saga middleware.to support the saga as a string cmf pattern you have the following api to use in your configure.js
Please check if the PR fulfills these requirements
[ ] This PR introduces a breaking change