Passing data between fragments with an Observable when X happens
<p>I'm fairly new to RxJava, and I was thinking if my problem could be solved with it.</p>

<p>I have an activity with two fragments: a header fragment hosted inside a CollapsingToolbarLayout, and a body fragment. The header fragment has a recycler view with posts, and the body fragment shows comments related to the current post shown in the header fragment.</p>

<p>Now, the comments are loaded immediately when the recycler view binds a post. However, I'd like to only load the comments when the user starts collapsing the toolbar. I have a listener set up for the toolbar which gets invoked when the user starts dragging the toolbar up, but I don't really know how to hook it up to the body fragment using the current post in the header fragment.</p>

<p>To describe it in pseudo-code, it's something like this:</p>

<pre><code>// Activity has this method invoked when toolbar starts collapsing;
// It's invoked only once per "drag"        
public void onToolbarCollapsing() {
    // Somehow should pass the Post to the body fragment..?
}

// The header fragment has this method invoked when a post is bound
public void onPostBound(Post post) {
    // Create an Observable&lt;Post&gt; and pass it to activity..?
}

// The body fragment could probably observe the observable?
</code></pre>

<p>At the moment, I have the <code>Activity</code> implement an <code>ActivityCallback</code>:</p>

<pre><code>public interface ActivityCallback {
    void loadCommentsFor(Post post);
}

public class MainActivity extends AppCompatActivity implements ActivityCallback {

    @Override void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Create fragments, set activity callback to the header fragment
        HeaderFragment header = new HeaderFragment();
        header.setActivityCallback(this);

        BodyFragment body = new BodyFragment();

        // Set fragments to the view etc.
    }

    // Implementation
    @Override
    public void loadCommentsFor(Post post) {
        // Just pass the post object to the body fragment
        bodyFragment.loadCommentsFor(post);
    }
}
</code></pre>

<p>Any ideas on how to tackle this?</p>