Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Offline First Web Development
Offline First Web Development

Offline First Web Development: Design and build robust offline-first apps for exceptional user experience even when an internet connection is absent

eBook
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Offline First Web Development

Chapter 2. Building a To-do App

In Chapter 1, The Pain of Being Offline, we laid the foundation for why offline-first development is important. Now, let's build an app with this approach. The app that we'll be building is a to-do app that has been written using the Sencha Touch JavaScript framework. As Sencha Touch is just JavaScript under the hood, you can view it in any browser. Additionally, if you're a mobile developer, fear not. We'll use Cordova to deploy your app to an iOS device as well. The section on Cordova is entirely optional and works for Android as well, with minor modifications along the way.

Let's start by getting your development environment configured. For simplicity, I assume that you're running Mac OS X and Chrome. The instructions may differ slightly with different operating systems and browsers. I'll call out the differences as we go along.

Configuring the development tools

There are three tools that we will use in most of the examples: a text editor for the coding, a browser (preferably Chrome) to run and debug your app, and the command line to run the web server and execute commands. Let's walk through each of these tools.

A text editor

If you have an existing editor that you like, use that. In this book, I will use Sublime Text 3. You can download a free evaluation of Sublime for OS X, Windows, and Linux. If you prefer to use a free editor, good choices include Notepad++ (Windows), Bluefish Editor (OS X and Linux), and GVIM (Linux). To install Sublime, follow these instructions:

  1. Open www.sublimetext.com in your browser.
  2. Click on Download.
  3. Click on Sublime Text 3.
  4. Choose the appropriate version for your operating system.
  5. Wait for the download to complete and run the installer.

You should be able to run Sublime now. It's a GUI-based editor that is very intuitive and simple to use. If you're interested in getting more...

Configuring Sencha Touch

Sencha Touch is a JavaScript-based MVC framework used to build cross-platform mobile apps. It's a proprietary framework but free for open source projects, so we'll use it for our to-do app. To get and configure it, follow these instructions:

  1. First we will download Sencha Touch:
    1. Open https://www.sencha.com/products/touch/ in your browser.
    2. Click on DOWNLOAD FOR FREE.
    3. Fill out the contact form and click on DOWNLOAD TOUCH.
    4. Check your e-mail for a link to download Sencha Touch.
    5. In the e-mail, click on Download Sencha Touch.
    6. After the download is complete, extract the ZIP in its own folder.
    7. Open this folder (it should be named touch-2.4.1 or similar).
  2. Install Sencha Cmd:
    1. Open https://www.sencha.com/products/extjs/cmd-download/ in your browser.
    2. Click on DOWNLOAD WITHOUT JRE INCLUDED.
    3. Once the download is complete, run the setup application.
    4. Accept all defaults and click on Install.
    5. Once the installation is complete, click on Finish.
  3. Install Ruby:
    1. Mac OS X: Ruby is preinstalled...

Creating a Git repository

This step is optional but highly recommended. It will prevent you from losing progress when you accidentally delete files and allow you to easily revert changes or try experiments without fear of diverging from the examples in the book.

You may also choose to use GitHub (or another code sharing site) to upload your code. This protects your code from hard drive failure and makes it easier to share and collaborate with others. Again, this step is optional but recommended. If you want to use Git and GitHub, perform the following steps:

First, we will install GitHub. The following instructions are for OS X only. If you're on Windows, download the GitHub client from windows.github.com and install it the way you would install other Windows applications:

  1. Open mac.github.com in your browser.
  2. Click on Download GitHub Desktop.
  3. After the download is complete, open the application.
  4. Click on Move to my application folder.
  5. Click on Continue.
  6. If you don't have a GitHub account...

Designing the offline experience

In the last section, you configured the tools necessary to make your app real. Now, let's step back and design the app in the context of some of the offline scenarios that we discussed in Chapter 1, The Pain of Being Offline.

What do users need from this app and why?

Designers often employ user stories to break a scenario into chunks. Each user story takes a person, describes a specific need that they have, and reveals the context behind the need. The format that we will use in this book is as follows:

  • As [a person]
  • I want [to accomplish a goal]
  • So that [context about the goal]

Let's talk briefly about each clause. How do user stories help us understand what we need to design and build?

  • As [a user]: This helps us understand who we're building for. If this person works with other people, we can (and should) consider how they will work together as a team. This is extremely important in communication-oriented products. Our simple to-do app considers...

Creating a skeleton application

Now, let's switch from design to code and create a skeleton Sencha Touch application. This will show us that the framework is functional and give us a base to start converting our workflows and wireframes into code.

Generating files with Sencha cmd

Using what you learned from setting up your development environment, switch to the todo-app directory that you used to create a repository. Now, generate a new application in this directory:

$ sencha -sdk /path/to/sdk/touch-2.4.1/ generate app TodoApp .

This will create a skeleton application with all the files needed. Now, verify that everything works as expected. You'll want two command windows open: one for the web server and the other for any commands that you need to run. In the first tab, start the web server:

$ sencha web start

In the second tab, preview the page in your browser:

$ open http://localhost:1841

If everything worked correctly, you should see the following sample app in your browser. You...

Configuring the development tools


There are three tools that we will use in most of the examples: a text editor for the coding, a browser (preferably Chrome) to run and debug your app, and the command line to run the web server and execute commands. Let's walk through each of these tools.

A text editor

If you have an existing editor that you like, use that. In this book, I will use Sublime Text 3. You can download a free evaluation of Sublime for OS X, Windows, and Linux. If you prefer to use a free editor, good choices include Notepad++ (Windows), Bluefish Editor (OS X and Linux), and GVIM (Linux). To install Sublime, follow these instructions:

  1. Open www.sublimetext.com in your browser.

  2. Click on Download.

  3. Click on Sublime Text 3.

  4. Choose the appropriate version for your operating system.

  5. Wait for the download to complete and run the installer.

You should be able to run Sublime now. It's a GUI-based editor that is very intuitive and simple to use. If you're interested in getting more out of Sublime...

Configuring Sencha Touch


Sencha Touch is a JavaScript-based MVC framework used to build cross-platform mobile apps. It's a proprietary framework but free for open source projects, so we'll use it for our to-do app. To get and configure it, follow these instructions:

  1. First we will download Sencha Touch:

    1. Open https://www.sencha.com/products/touch/ in your browser.

    2. Click on DOWNLOAD FOR FREE.

    3. Fill out the contact form and click on DOWNLOAD TOUCH.

    4. Check your e-mail for a link to download Sencha Touch.

    5. In the e-mail, click on Download Sencha Touch.

    6. After the download is complete, extract the ZIP in its own folder.

    7. Open this folder (it should be named touch-2.4.1 or similar).

  2. Install Sencha Cmd:

    1. Open https://www.sencha.com/products/extjs/cmd-download/ in your browser.

    2. Click on DOWNLOAD WITHOUT JRE INCLUDED.

    3. Once the download is complete, run the setup application.

    4. Accept all defaults and click on Install.

    5. Once the installation is complete, click on Finish.

  3. Install Ruby:

    1. Mac OS X: Ruby is preinstalled. Verify...

Creating a Git repository


This step is optional but highly recommended. It will prevent you from losing progress when you accidentally delete files and allow you to easily revert changes or try experiments without fear of diverging from the examples in the book.

You may also choose to use GitHub (or another code sharing site) to upload your code. This protects your code from hard drive failure and makes it easier to share and collaborate with others. Again, this step is optional but recommended. If you want to use Git and GitHub, perform the following steps:

First, we will install GitHub. The following instructions are for OS X only. If you're on Windows, download the GitHub client from windows.github.com and install it the way you would install other Windows applications:

  1. Open mac.github.com in your browser.

  2. Click on Download GitHub Desktop.

  3. After the download is complete, open the application.

  4. Click on Move to my application folder.

  5. Click on Continue.

  6. If you don't have a GitHub account already...

Left arrow icon Right arrow icon

Key benefits

  • ? Understand the design principles behind a well-designed offline experience
  • ? Create the illusion of being online when you’re really offline
  • ? Use common libraries such as Sencha Touch and PouchDB to enhance the offline experience of mobile apps

Description

When building mobile apps, it’s easy to forget about the moments when your users lack a good Internet connection. Put your phone in airplane mode, open a few popular apps, and you’ll quickly see how they handle being offline. From Twitter to Pinterest to Apple Maps, some apps might handle being offline better—but very few do it well. A poor offline experience will result in frustrated users who will abandon your app, or worse, turn to your competitor’s apps Expert or novice, this book will teach you everything you need to know about designing and building a rigorous offline app experience. By putting the offline experience first, you’ll have a solid foundation to build upon, avoiding the unnecessary stress and frustration of trying to retrofit offline capabilities into your finished app. This basic principle, designing for the worst-case scenario, could save you countless hours of wasted effort.

Who is this book for?

Do you want to make your app experience more robust and delightful? Are you eager to write apps that cater to a wider audience, not just the Silicon Valley crowd? Do you need to persuade your peers that offline-first is a worthwhile development paradigm? If your answer to all or any one of these questions is yes, then this is the book is for you. Some previous coding and command-line experience would be useful, but is not required.

What you will learn

  • ? Design the behavior of the app, taking offline, online, and the transition between those two states into account
  • ? Seamlessly implement the offline/online experience that you've designed using Sencha Touch and PouchDB
  • ? Show the user what's happening under the hood with online/offline indicators and Good Mobile Messaging1
  • ? Employ various strategies to cope with unreliable network conditions
  • ? Help the user resolve conflicts related to the “split-brain” problem
  • ? Choose intelligent defaults based on usage of the app
  • ? Use point-to-point networking to partially overcome a lack of Internet connectivity

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 20, 2015
Length: 316 pages
Edition : 1st
Language : English
ISBN-13 : 9781785885662
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Nov 20, 2015
Length: 316 pages
Edition : 1st
Language : English
ISBN-13 : 9781785885662
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 103.97
Responsive Web Design with HTML5 and CSS3, Second Edition
€41.99
Offline First Web Development
€36.99
Mobile Web Performance Optimization
€24.99
Total 103.97 Stars icon
Banner background image

Table of Contents

11 Chapters
1. The Pain of Being Offline Chevron down icon Chevron up icon
2. Building a To-do App Chevron down icon Chevron up icon
3. Designing Online Behavior Chevron down icon Chevron up icon
4. Getting Online Chevron down icon Chevron up icon
5. Be Honest about What's Happening Chevron down icon Chevron up icon
6. Be Eventually Consistent Chevron down icon Chevron up icon
7. Choosing Intelligent Defaults Chevron down icon Chevron up icon
8. Networking While Offline Chevron down icon Chevron up icon
9. Testing and Measuring the UX Chevron down icon Chevron up icon
A. References Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
(1 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 100%
1 star 0%
Dmytro K. Apr 06, 2020
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
This book has nothing to do with architecture as I thought by reading the title. It says "Offline First Web Development", but then on the next line it says "Design and implement a robust offline app experience using Sencha Touch and PouchDB", which is already a much narrower scope than "offline first". Then the book itself is mostly a manual of which tools and how to install on macOS (of course that's the platform you are using for development!)If you have not purchased this book first read the title page fully and try to browse through some pages
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.