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

Some improvements... #95

Merged
merged 7 commits into from
Aug 11, 2022
Merged

Some improvements... #95

merged 7 commits into from
Aug 11, 2022

Conversation

semoal
Copy link
Contributor

@semoal semoal commented Aug 5, 2022

Will fix:

#89 Incompatible with React versions >16
#40 is this hooks automatically disconnect channels?
#43 Introduce to hoist channel connection
#44 useChannel(false) to prevent eager channel connection

src/core/useChannel.ts Outdated Show resolved Hide resolved
Copy link
Owner

@mayteio mayteio left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! This definitely needed some love, I think it's two-three years old now. I'm happy with these changes, please get tests passing and we can merge. Does this introduce any breaking changes?

src/core/PusherProvider.tsx Outdated Show resolved Hide resolved
/** Return channel */
return connectedChannels.current[channelName][0] as T;
},
[connectedChannels, client]
Copy link
Owner

Choose a reason for hiding this comment

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

probably don't need connectedChannels in dependencies as it's a ref. Why did you opt for a ref rather than useState? Wouldn't useState refresh all the subscribers to get the updated channels?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've tried with useState but subscribe and unsubscribe reference changes every time connectedChannels changes, this makes useChannel useEffect to runs infinitely, tried with useCallbacks, useMemos, even using the callback of the setState instead of using the value of the state. Found the most stable option using the ref.

Probably I'm missing something, but couldn't get it work with useState :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, with useState if some parent context changes, will lose all the connections right?

src/core/ChannelsProvider.tsx Show resolved Hide resolved
Copy link
Owner

@mayteio mayteio left a comment

Choose a reason for hiding this comment

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

Just saw we don't even run tests in CI!

@semoal
Copy link
Contributor Author

semoal commented Aug 7, 2022

Just saw we don't even run tests in CI!

We'll do now, just pushed a github action that runs the test suite ;)

@semoal semoal requested a review from mayteio August 8, 2022 18:15
@semoal
Copy link
Contributor Author

semoal commented Aug 9, 2022

Let's see if we can get this merged/reviewed soon @mayteio don't want to introduce you hurry, we're using my fork meanwhile, but I'll prefer to use yours :)

@mayteio
Copy link
Owner

mayteio commented Aug 10, 2022

Thanks @semoal, sorry I'm not seeing the GitHub action in the checks?

@semoal
Copy link
Contributor Author

semoal commented Aug 10, 2022

Thanks @semoal, sorry I'm not seeing the GitHub action in the checks?

GitHub only runs actions that are on main/master branch. If you want cherry pick the action to main I can update the branch and the CI will run 👍

They made that cuz the crypto mining, if you haven’t any ci first has to be on main to run on branches, and then when on main if the pull request is open and first contributor, needs approval from you to run 🥵

@mayteio mayteio merged commit 7ac463b into mayteio:master Aug 11, 2022
@mayteio
Copy link
Owner

mayteio commented Aug 11, 2022

Nice, thanks @semoal! Approved and merged.

@semoal semoal deleted the improvements branch August 12, 2022 07:38
@antonykamp
Copy link

Hey guys 😇 Thanks, @semoal, for the fantastic improvements and @mayteio for merging.
I would like to ask if you can publish the new version on npm, please 🙃
It would help us a lot! Thanks.

@fotoflo
Copy link

fotoflo commented Nov 28, 2023

Hi im still seeing that it's incompatible with react 18... is that the case? or should i use --legacy-peer-deps (i don't like to do that...)

$ npm install @harelpls/use-pusher
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR! react@"18.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.9.0" from @harelpls/[email protected]

@JCMais
Copy link

JCMais commented Dec 14, 2023

@mayteio could you publish a new version with these fixes?

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.

5 participants