Last active
December 23, 2015 11:39
-
-
Save loganj/6630117 to your computer and use it in GitHub Desktop.
This is probably a bad idea.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.squareup.otto; | |
/** | |
* A bus which supports detaching from its parent and attaching new children. | |
* | |
* THIS IS A THOUGHT EXPERIMENT. Don't freak out. | |
*/ | |
public interface DetachableBus extends Bus { | |
/** | |
* Detach bus from its parent, making it a {@link Root}. | |
* | |
* Idempotent on roots. | |
*/ | |
Root detach(); | |
/** | |
* Make this bus the parent of the given bus. | |
* | |
* @throws IllegalArgumentException if child already has a parent (is not a root). | |
*/ | |
void attach(Bus child); | |
/** @see com.squareup.otto.Bus#spawn() */ | |
@Override DetachableBus spawn(); | |
interface Root extends DetachableBus { | |
/** | |
* Turn on delivery of events to subscribers on the entire tree. | |
*/ | |
void enableDelivery(); | |
/** | |
* Turn off delivery of events to subscribers on the entire tree. Any attempted posts while | |
* delivery is disabled will result in a call to the dead event handler. | |
*/ | |
void disableDelivery(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thought this through a bit more. Has major problems with calls made during handler execution. I'm shelving the whole idea for now, more trouble than it's worth. Here are my notes: