Git Product home page Git Product logo

Comments (7)

swankjesse avatar swankjesse commented on July 30, 2024

We should add this to the FAQ 'cause it keeps coming up and I think we want to keep saying No. If you depend on the order of event notifications, then you probably shouldn't be using Otto. We want different components of your app to handle events without worrying about the source of those events. And they also shouldn't by worrying about other subscribers to those events. If the order of events matters, then there are interdependencies between the subscribers and Otto is hiding those interdependencies. In this case you're better off with strong coupling, like listeners or some kind of controller pattern.

from otto.

ajostergaard avatar ajostergaard commented on July 30, 2024

@swankjesse Does your emphatic no include the idea of providing some way for the source of the events to know whether there actually were any subscribers at all?

from otto.

swankjesse avatar swankjesse commented on July 30, 2024

@ajostergaard what's your use case? To detect bugs?

from otto.

pforhan avatar pforhan commented on July 30, 2024

@ajostergaard Otto will post com.squareup.otto.DeadEvent events if there were no subscribers, if that helps.

from otto.

ajostergaard avatar ajostergaard commented on July 30, 2024

@swankjesse - no, to make sure somebody dealt with the event so that the source can handle it as a fallback (e.g. by raising a Notification as per commonsguy).

@pforhan - if the DeadEvent comes loaded with enough of the original event then that certainly helps. :) Is there any documentation on the events Otto raises? Perhaps I've just been completely blind?!?

Actually I asked this question before finding out that LocalBroadcastManager returns false if there were no subscribers so I kind of don't need this anymore anyway - sorry for the 'noise'!

from otto.

imminent avatar imminent commented on July 30, 2024

@ajostergaard as for the DeadEvent coming loaded with enough of the original event, it just wraps the original event:

/**
  * Creates a new DeadEvent.
  *
  * @param source object broadcasting the DeadEvent (generally the {@link Bus}).
  * @param event the event that could not be delivered.
  */
  public DeadEvent(Object source, Object event) {
    this.source = source;
    this.event = event;
  }

from otto.

ajostergaard avatar ajostergaard commented on July 30, 2024

Thanks guys. :)

from otto.

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.