Isomorphic Handoff

In the development of Isomorphic Go web applications, two critical techniques were introduced in the previous two chapters. First, you learned how to utilize an in-memory template set to render templates across environments. Second, you learned how to perform end-to-end routing on both the client and the server. Client-side routing is the magic that allows the client-side web application to operate in the single page mode.

The aforementioned techniques now provide us with the ability to navigate to different sections of the website, on the client itself, and render any given template across environments. As the implementors of an Isomorphic Go web application our responsibility is to ensure that state is maintained between the client and the server. For example, when rendering the Products page, it wouldn't make sense if the list of products was rendered differently on the client side than it was on the server side. The client needs to work in lockstep with the server to ensure that the state, in this case, the list of products is maintained—and that's where isomorphic handoff comes into the picture.

Isomorphic handoff is the process by which the server hands off state to the client and the client uses the passed state to render the web page on the client side. Keep in mind that the state the server passes off to the client must include the exact same state that was used to render the server-side web page response. Isomorphic handoff essentially allows the client to seamlessly pick up things where they were left off on the server. In this chapter, we'll revisit the product-related pages, to see exactly how the state is maintained from the server side to the client side. In addition to that, we will also complete the implementation of the product-related pages, by implementing the user interactivity portions, which involve adding event handlers to the Add To Cart buttons found in these pages.

The shopping cart feature for the IGWEB website will be implemented in this chapter, and it will allow us to consider the scenario where the user can change the state of the shopping cart by adding and removing items to and from the shopping cart. We will use isomorphic handoff to ensure that the current state of the shopping cart is seamlessly maintained across the server and the client. By properly maintaining the state of the shopping cart we can guarantee that the shopping cart page rendered from the server side always matches the shopping cart page rendered from the client side.

In this chapter, we will cover the following topics:

  • The isomorphic handoff procedure
  • Implementing isomorphic handoff for the product-related pages
  • Implementing isomorphic handoff for the shopping cart
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.101.81