Implementing the createBook method

Next up is the createBook method. This is the most complicated one.

First of all, implement all the required validations:

createBook(collectionIdentifier: string): void {    if (!collectionIdentifier) {        throw new Error("The collection identifier is required to         create a new book!");    }    console.log("Retrieving the details about the new book to     create...");    const bookDetailsResult =     this._view.getNewBookDetails(collectionIdentifier);    if (bookDetailsResult.error) {        console.error("Failed to retrieve the book details: ",         bookDetailsResult.error);        return;    }    if (!this._bookCollections.has(collectionIdentifier) ||     !this._bookCollections.get(collectionIdentifier)) {        console.error("Tried to add a book to an unknown ...

Get Learn TypeScript 3 by Building Web Applications now with O’Reilly online learning.

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