Chapter 11. Navigating offline data

 

This chapter covers

  • Handling browser navigation in a single-page app
  • Storing cookies to remember user settings
  • Serializing objects to JSON
  • Storing offline data in the browser

Users are accustomed to using built-in browser navigation tools, such as the browser’s forward and back buttons and bookmarks, to navigate web apps in the same way they have been doing for years with normal websites. Users also expect apps to have fast response times, which apps achieve by persisting data offline.

Modern browser technology makes it possible to meet your users’ expectations. In this chapter you’ll add these features to the DartExpense example application you started in the previous chapter.

In a single-page web app, when the user switches between two views, such as from list view to edit view, they expect to be able to use the browser’s back button to navigate back to the prior view. Your app, therefore, needs be able to notify the web browser that a view change has occurred. We’ll look at how you can manipulate the browser’s history to make it possible to use back-button navigation and to bookmark specific views.

After exploring a mechanism for navigating using the standard browser navigation tools, we’ll examine how you can store user settings in cookies. This will allow the app to return to the same view the user was visiting when they closed the browser.

11.1. Integrating navigation with the browser

11.2. Using browser cookies to enhance user experience

11.3. Persisting data offline with Web Storage

11.4. Summary