Giving DataStore a Promise

By returning Deferreds from RemoteDataStore’s methods, you have a flexible way to use the data sent back from the server.

But you may have noticed that RemoteDataStore’s methods now stray far away from how DataStore’s methods work. If you were to swap a regular DataStore back in, you would see that it no longer works with your application (Figure 14.6).

Figure 14.6  Uh oh. DataStore is no longer compatible

Uh oh. DataStore is no longer compatible

In Figure 14.6, you can see that instantiating a Truck with a regular DataStore throws errors and fails to work correctly with the UI. CoffeeRun expects a Promise-based DataStore in order to function ...

Get Front-End Web Development: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.