Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6938961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:33:30+00:00 2026-05-27T12:33:30+00:00

In google io 2011, David Chandler mentioned that you can chain different request context

  • 0

In google io 2011, David Chandler mentioned that you can chain different request context by using append() method,but in practice, I don’t know how to chain them up while they have different receiver,using to() and then fire()?

Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:33:31+00:00Added an answer on May 27, 2026 at 12:33 pm

    There are two kinds of receivers: the ones bound to each method invocation (that you pass to the Request‘s to() method), and the context-level one (that you pass to the RequestContext‘s fire() method). The Request‘s fire(Receiver) method is a short-hand for to(receiver).fire(), i.e. it binds the Receiver to the method.

    The method-level receivers depend on the method only, their generic parameterization depends on the method’s return value (the generic parameterization of the Request or InstanceRequest), so whether you append() several RequestContexts together changes absolutely nothing.

    The context-level receiver is always parameterized with Void. When you append() contexts together, they actually form a single context with several interfaces, so you only call fire() once, on any one of the appended contexts.

    Now let’s go back to the basics: without using append(), you can only batch together calls for methods that are declared on the context interface. If you have two distinct context interfaces you want to use, you have to make two fire(), i.e. two HTTP requests. The introduction of append() allows you to batch together calls for methods declared on any context interface: simply append a context to another one and the calls on both contexts will be batched together in the same HTTP request, triggered by a unique fire() on any one of the context being appended.

    Now into the technical details: internally, a context is nothing more than a thin wrapper around a state object. When you edit() or create() a proxy, you add it to the internal state, and when you call a service method, the method name (actually, its obfuscated token) and the arguments are captured and pushed to the state as well. When you append() a context, you’re only making it share its internal state with the one of the context you append it to. That way, when you call a service method on the appended context, its pushed on the exact same state as the one of the other context, and when you fire() any one of them, the state is serialized into a single HTTP request.
    Note that, to append a context, its own internal state has to be empty, otherwise an exception will be raised, as the state would be thrown away to be replaced by the one of the other context.

    In brief, and in practice:

    FirstContext first = rf.first();
    SomeProxy proxy = first.create(SomeProxy.class);
    ...
    SecondContext second = first.append(rf.second());
    OtherProxy other = second.create(OtherProxy.class);
    other.setSome(proxy);
    ...
    second.saveAndReturnSelf(other).to(new Receiver<OtherProxy>() {
       ...
    });
    ...
    first.fire();
    

    Note that the line that creates and appends the second context could equally be written:

    SecondContext second = rf.second();
    first.append(second);
    

    The append method returns its argument as a convenience, but it’s really the same value you passed as the argument. This is only to allow writing the one-liner above, instead of being forced to use the two-liner.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Google results on this one are a bit thin, but suggest that it is
In this video from Google I/O 2011, Google says you can use the Android
I receive this date format from facebook and google docs: 2011-02-25T10:55:25+0000 How can I
Does Google Apps Script use a funky version of EcmaScript that can't parse a
Google announced via their Geo Developers Blog on April 08, 2011 that as of
I want to make a UI that's similar to Google Reader's list view: http://dl.dropbox.com/u/2792776/screenshots/2011-12-24_1807.png
Google maps in some region can serve traffic information showing the blocked roads and
Google/MyBrain are failing me. Without using a framework (which I'll never get past my
After Google discontinued its support of Android App Inventor on December 31st 2011, it
After doing some search on SO, Google and MSDN forums I've become frustrated that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.