Coder Social home page Coder Social logo

Comments (6)

NimaAra avatar NimaAra commented on July 23, 2024 1

Okay thanks, this should now be fixed in v3.3.0

Please validate and let me know how it goes.

from easy.messagehub.

NimaAra avatar NimaAra commented on July 23, 2024

This should not be the case. The idea is that MessageHub will be registered against IMessageHub in a container and only the class initializing the container or the container itself should be able to dispose the hub otherwise a consumer (publisher or subscriber) could by mistake dispose the hub resulting in other consumers being unable to publish or subscribe.

from easy.messagehub.

bed007 avatar bed007 commented on July 23, 2024

When the hub is registered in a Ioc container (DryIoc for instance) as a Singleton, when the container is disposed to clear all registration, the hub is also Disposed which is OK. The problem is that, once the hub is disposed, there is notting else to do to instanciate a new hub instance. The IMessageHub singleton instance is disposed and unusable and since the ctor is private, there is no way to have a working hub again. We need to kill the process. Any solution or fix in mind ?

from easy.messagehub.

bed007 avatar bed007 commented on July 23, 2024

Ok, in DryIoc there is a flag you can set to prevent it from calling Dispose on a registration. But I think that having a hub that cannot work anymore and the only solution is to kill the process is a bad thing.. no ?

from easy.messagehub.

NimaAra avatar NimaAra commented on July 23, 2024

That is a valid ask.

My question to you so that I can understand your use-case better is why would you want to dispose the hub and then use it again?

The reasoning behind the current behaviour is that you would only dispose it at the application/process exit, if your intent is to clear existing subscriptions then why not invoke the relevant method?

from easy.messagehub.

bed007 avatar bed007 commented on July 23, 2024

Well I agree this is not a common case. What is happening is that we are using it in a Xamarin.Forms application. The actual steps to reproduce my case are the following (for Android only):

  1. Boostrap the DryIoc container by registering all services when MainActivity (XF apps are typically single activity apps)
  2. Do stuff...
  3. Back button is pressed at the root page, the MainActivity is then Destroyed. At this point, we want to Dispose the DryIoc which call Dispose on all IDisposable registration.
  4. We start the application from the launcher icon again. At this point, and this is the uncommon part (!), the MainActivity is created again and the container is getting boostrapped again. But since we just destroy the MainActivity but did not kill the application, the App was still "alive" and all static content was preserved, thus the MessageHub is disposed and cannot be used anymore.

The main point here is that calling Dispose on the MessageHub make the whole library useless after that point. There is no way of getting the MessageHub up again in the same process.

from easy.messagehub.

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.