Comments (7)
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.
@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.
@ajostergaard what's your use case? To detect bugs?
from otto.
@ajostergaard Otto will post com.squareup.otto.DeadEvent
events if there were no subscribers, if that helps.
from otto.
@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.
@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.
Thanks guys. :)
from otto.
Related Issues (20)
- duplicate entry: com/squareup/otto/AnnotatedHandlerFinder.class HOT 1
- NoClassDefFoundError when running in Android OS below 5.0. HOT 3
- subcriber received two same event HOT 2
- Please include the deprecated notice in the info website
- Examples HOT 1
- Please add notice to website about otto deprication HOT 1
- How to customize ThreadEnforcer HOT 4
- Using privitives in callback haven't invoked it. HOT 3
- Link for Migrating to RxJava is dead. HOT 1
- Private EventHandler makes it impossible to override Bus#dispatch HOT 1
- OnEvent not calling in navigationdrawer fragment
- otto with JavascriptInterface in api < 17 HOT 1
- Ship proguard rules in the aar? HOT 1
- A new call to post in a subscriber does not call its subscribers until the first call is completed HOT 1
- Reason for its name HOT 1
- android.database.sqlite.SQLiteException: no such table HOT 4
- Update for Gradle 4 and Bus doesnt work more. HOT 3
- I can't receive the event HOT 1
- java.lang.RuntimeException: Could not dispatch event: class abc to handler
- java.lang.RuntimeException: Could not dispatch event HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from otto.