Go ahead and get your paper and pencil out again. We need to design the data model for the app. We'll have two portions: one to manage the list of available documents, and another to manage a single document.
Here's what our model looks like:
The first model, named FilerDocuments, is responsible for managing all the files available to the app, while the one on the right, named FilerDocument, is responsible only for a single note. The latter is responsible for loading a note and saving a note, while the former is responsible for reading an entire directory of notes and then managing them via renames, copies, and deletes.
A few notes of interest before we wrap this task up. Notice all methods that end with …Success
. This is simply due to the way the File API is structured; everything is done asynchronously so you have to write each call to it with callbacks to both a success
and a failure
function. The success
function points at the corresponding Success...