Code Monkey home page Code Monkey logo

react-query-subscription's People

Contributors

allcontributors[bot] avatar cabljac avatar kaciakmaciak avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-query-subscription's Issues

Retry doesn't succeed after the connection got closed

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

✨ Add `fromEventSource` and `eventSource$` helpers

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>;

Multiple components subscribed with the same subscription key

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:

Screenshot 2023-05-02 at 10 53 42

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?

Support react-query v5

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:

  1. Use react-query-subscription together with react-query v5

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):

  • Node version: v20
  • React Query version: 5
  • OS: Ubuntu
  • Browser: any

[question]: query kept in "fetching" state

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).

CleanShot 2022-09-21 at 10 56 38
CleanShot 2022-09-21 at 10 57 49

Build for react native

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.

The automated release is failing 🚨

🚨 The automated release from the 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.


Invalid npm token.

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 πŸ“¦πŸš€

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.