Skip to content
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: Expose real time dispatch changes function #1532

Merged
merged 3 commits into from
Sep 19, 2024

Conversation

zatteo
Copy link
Contributor

@zatteo zatteo commented Sep 18, 2024

When in a React environment, we use the RealTimeQueries component to subscribe to a doctype changes and keep the internal store updated.

To be able to do the same thing manually for non React environment, we expose the underlaying functions : dispatchCreate, dispatchCreate, dispatchDelete.

Copy link
Contributor

@paultranvan paultranvan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! Just a small remark on jsdoc

packages/cozy-client/src/RealTimeQueries.jsx Outdated Show resolved Hide resolved
When in a React environment, we use the RealTimeQueries component to
subscribe to a doctype changes and keep the internal store updated.

To be able to do the same thing manually for non React environment,
we expose the underlaying functions : dispatchCreate, dispatchCreate,
dispatchDelete.
If `CozyClient` is imported into those files, then unit tests fail.

Using `@param {import('../CozyClient').default} client` syntax
doesn't work either as this syntax is not handled by `jsdoc`.

Jsdoc seems to support this syntax in later versions but then
node engine should be updated.

So client will be temporarily typed as `object` until a better solution
is found.
@@ -1,6 +1,5 @@
import { Mutations } from '../queries/dsl'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really nitpicking, but why the plural in realtimes.js? There is only one, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... I should change it. It was because other file were plurals in the folder...

@@ -22,7 +21,7 @@ const normalizeDoc = (couchDBDoc, doctype) => {
/**
* DispatchChange
*
* @param {CozyClient} client CozyClient instane
* @param {object} client CozyClient instane
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing the CozyClient type?

Copy link
Contributor Author

@zatteo zatteo Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had issues with tests when moving the functions in the a file that is imported and exported in /store/index. I found other commit fixing the same issue. Here is the explanation.

If `CozyClient` is imported into those files, then unit tests fail.

Using `@param {import('../CozyClient').default} client` syntax
doesn't work either as this syntax is not handled by `jsdoc`.

Jsdoc seems to support this syntax in later versions but then
node engine should be updated.

So client will be temporarily typed as `object` until a better solution
is found.

@zatteo zatteo merged commit 4aa9ab0 into master Sep 19, 2024
4 checks passed
@zatteo zatteo deleted the feat/realtime-direct-update branch September 19, 2024 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants