Day 2: Exchanging Notes

Or, Creating Notes and Calling the API

Today we’ll write the code to accept user input and create a note from the new note screen. Then we’ll get the notes displayed in a list on the main screen. We’ll also get the notes saving to and loading from the API.

Creating a New Note

Let’s get started by creating a new note. First, to store note data locally we’ll create a data model.

Creating a Note Data Model

Add this class to a new file called data/NotesDataModel.js:

 'use strict'​;
 class​ NotesDataModel {
  notes:Array<Object> = [];
  createNewNote(title​:​String, body​:​String) {
 this​.notes.push({title: title, body: body});

Get Seven Mobile Apps in Seven Weeks now with the O’Reilly learning platform.

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