Giter VIP home page Giter VIP logo

Comments (8)

mayteio avatar mayteio commented on June 5, 2024

Thanks for letting me know. Do you have a codesandbox that reproduces this?

from use-pusher.

underfisk avatar underfisk commented on June 5, 2024

@201524547 It was something i had reported time ago, it disconnects and never re-connects back to the channel if the component re-renders
@mayteio All you have to do is simply have a component that with a parent or some dependency that make it re-render and test having the useChannel with some useEvent and you'll notice the first time pusher invokes your callback its okay but the 2nd time after component gets re-rendered it just unbinds the channel (disconnecting or not) and the callbacks are no longer doing anything

from use-pusher.

mayteio avatar mayteio commented on June 5, 2024

Please provide a codesandbox - I do not have this issue.

from use-pusher.

underfisk avatar underfisk commented on June 5, 2024

Sure i'll do that but i think i found why its probably happening, let me explain it quickly
There are types of channels that need to be persisted while the application is on, usually those are bounded to the user itself and not to the component, useChannel makes it unsubscribe on unmount and what if a component uses a user room that needs to be alive while the app is running? That was in fact one of the issues, my workaround was creating a custom useChannel that just simply doesn't unsubscribe but removes the event only but i think there is room for improvement.
Do you think that considering a parameter option whether we can unsubscribe or not? It does make sense having it unsubscribing on unmount but sometimes you don't want that channel to go away in sub-components, not sure what's your suggestion in here. Once i have some free time i'll publish here the issue

from use-pusher.

mayteio avatar mayteio commented on June 5, 2024

Hey, why don’t you move the useChannel hook higher up into a provider? That way it can live connected for the duration of the session.

from use-pusher.

underfisk avatar underfisk commented on June 5, 2024

At some point if my event uses that channel somehow its unsubscribing, i tried that but i can check again
What i ended up doing is check if the channel exists and re-use but never close it (only the higher up provider) is closing it
but probably i might be doing something wrong

from use-pusher.

mayteio avatar mayteio commented on June 5, 2024

Might #43 solve this too?

from use-pusher.

jan-wilhelm avatar jan-wilhelm commented on June 5, 2024

yeah, I ran into the same problem and (as far as I can tell), #43 would solve this perfectly.

from use-pusher.

Related Issues (20)

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.