kaciakmaciak / react-query-subscription Goto Github PK
View Code? Open in Web Editor NEWHook based on React Query for managing, caching and syncing observables in React
License: MIT License
Hook based on React Query for managing, caching and syncing observables in React
License: MIT License
Currently, release commits are committed by semantic-release-bot.
Hi,
I've an issue with my WS connection getting closed by the server side from time to time.
I expected the retry mechanism to work in that case, but all it does seems to error out right away. Refreshing my app makes the connection succeed right away though.
Is there a supported way to re-initiate the whole connection and subscription on retry?
FWIW I'm using the beta 2.0.0-beta.1 version with react query v4
Make react-query-subscription
compatible with react-query@4
.
setLogger
is removed (v4)Add examples how to use useSubscription
to readme and add to /examples
directory with code examples.
So that consumer of useSubscription
can use EventSource with ease.
Type declarations might look as follows:
export declare function fromEventSource<TData>(sse: EventSource, events?: string[]): Observable<TData>;
export declare function eventSource$<TData = unknown>(url: string, configuration?: EventSourceInit, options?: EventSourceOptions<TData>): Observable<TData>;
I noticed that if I use the same subscription in multiple places in my app, it creates a new subscription. In my app I have 4 places where I am using the subscription's data, and in the WS debug tool I see it creates 4 subscriptions:
Wouldn't it be more efficient to reuse the same subscription? I am coming from the mental model of react-query where I can have many useQuery
hooks and the API/backend only ever gets called once.
Here is my hook:
function fetcher() {
return fromWsClientSubscription({
query: PositionDocument,
})
}
export function usePosition() {
let subscription = useSubscription(
['position'],
fetcher,
{
select: (data) => data?.flowQueueUpdated?.position ?? null,
},
)
return subscription?.data ?? null
}
So my question or feature request is that can this hook not reuse the same data inside each useQuery hook? Why does it need to open a new subscription on each use of the hook?
Resolve security alerts in https://github.com/kaciakmaciak/react-query-subscription/security/dependabot
Describe the bug
react-query-subscription doesn't support react-query v5, see error below "No matching export for import "hashQueryKey""
Indeed, it has been renamed to hashKey
see https://tanstack.com/query/latest/docs/framework/react/guides/migrating-to-v5#hashquerykey-has-been-renamed-to-hashkey
To Reproduce
Steps to reproduce the behavior:
Expected behavior
No error
Screenshots / Error
There's an error at compilation
β [ERROR] No matching export in "../../node_modules/@tanstack/react-query/build/modern/index.js" for import "hashQueryKey"
../../node_modules/react-query-subscription/es/use-infinite-subscription.js:3:9:
3 β import { hashQueryKey, useInfiniteQuery, useQueryClient } from '@tanstack/react-query';
Context (please complete the following information):
Not sure if I'm doing anything wrong, but when I connect to a "server" (esp32 with EventSource), and I can check on the chrome network panel that the data is coming from the server and the connection is working, but on the react-query side, the query stays in "fetching" state.
If I send corrupted data (e.g.: "hello world" in plain text), then it throws an error (as expected).
See React Query Docs
Currently the umd build has old version in the banner, this is due to build step running prior release.
See https://unpkg.com/[email protected]/dist/react-query-subscription.production.min.js as an example.
Currently, running git commit doesn't fix lint issues automatically. Fix it, so that once changes are committed and push to GitHub, they pass the "Lint" step in the CI.
npm audit fix
and more.
Add CI for beta releases
See React Query Docs
onData
is called whenever new value is emitted.
https://www.gitpod.io/blog/gitpodify/
https://www.gitpod.io/docs/config-start-tasks
Is your feature request related to a problem? Please describe.
The library doesn't work with react native.
Describe the solution you'd like
Make it work.
From React Query v3.30.0 an AbortSignal
is provided to queryFn
, so that the requests can be cancelled.
Implement cancellation for useSubscription
.
Relates to #60
Auto generate docs from JSDoc & Typescript.
useSubscription
options.master
branch failed. π¨I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. Iβm sure you can fix this πͺ.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here are some links that can help you:
If those donβt help, or if this issue is reporting something you think isnβt right, you can always ask the humans behind semantic-release.
The npm token configured in the NPM_TOKEN
environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/
.
If you are using Two Factor Authentication for your account, set its level to "Authorization only" in your account settings. semantic-release cannot publish with the default "
Authorization and writes" level.
Please make sure to set the NPM_TOKEN
environment variable in your CI with the exact value of the npm token.
Good luck with your project β¨
Your semantic-release bot π¦π
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.