• Complain

Kereki Federico - Modern JavaScript Web Development Cookbook: Easy solutions to common web development problems with coverage on React, Node.js, and Microservices

Here you can read online Kereki Federico - Modern JavaScript Web Development Cookbook: Easy solutions to common web development problems with coverage on React, Node.js, and Microservices full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. City: Birmingham;England, year: 2019;2018, publisher: Packt Publishing, genre: Home and family. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

No cover
  • Book:
    Modern JavaScript Web Development Cookbook: Easy solutions to common web development problems with coverage on React, Node.js, and Microservices
  • Author:
  • Publisher:
    Packt Publishing
  • Genre:
  • Year:
    2019;2018
  • City:
    Birmingham;England
  • Rating:
    4 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 80
    • 1
    • 2
    • 3
    • 4
    • 5

Modern JavaScript Web Development Cookbook: Easy solutions to common web development problems with coverage on React, Node.js, and Microservices: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Modern JavaScript Web Development Cookbook: Easy solutions to common web development problems with coverage on React, Node.js, and Microservices" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Modern recipes to help you write cleaner code, solve common JavaScript problems, and work on popular use cases such as Microservices, Native Mobile development, and moreKey Features Build, test, and deploy robust and scalable Microservice and serverless web apps Develop your own serverless applications that are scalable and efficient Combine server-side functionality with web development abilities to produce native applications Book DescriptionJavaScript has evolved into a language that you can use on any platform. Modern JavaScript Web Development Cookbook is a perfect blend of solutions for traditional JavaScript development and modern areas that developers have lately been exploring with JavaScript. This comprehensive guide teaches you how to work with JavaScript on servers, browsers, mobile phones, desktops, along with the Internet of Things (IoT).You will start by exploring the new features of ES8. You will then move on to learning the use of ES8 on servers (with Node.js), with the objective of producing services and Microservices and dealing with authentication and CORS. Once you get accustomed to ES8, you will learn to apply it to browsers using frameworks, such as React and Redux, which interact through Ajax with services. You will then understand the use of a modern framework to develop the UI. In addition to this, development for mobile devices with React Native will walk you through the benefits of creating native apps, both for Android and iOS.The knowledge of server-side tools and React for client-side development will be used to develop desktop applications. Towards the end of the book, you will get to grips with creating and developing applications for the Internet Of Things with Cloud Native development.What you will learn Use the latest features of ES8 and learn new ways to code with JavaScript Develop server-side services and microservices with Node.js Build client-side web applications using React and Redux Create native mobile applications for Android and iOS with React Native Write desktop applications with Electron Develop IoT applications using Cloud Native platforms and serverless architectures Who This Book Is ForThis book is for you if you want to explore the latest JavaScript features, frameworks, and tools to build complete web applications, including server- and client-side code. A basic working knowledge of JavaScript would be beneficial, as you will be introduced to the latest version of ES8 (2017).

Kereki Federico: author's other books


Who wrote Modern JavaScript Web Development Cookbook: Easy solutions to common web development problems with coverage on React, Node.js, and Microservices? Find out the surname, the name of the author of the book and a list of all author's works by series.

Modern JavaScript Web Development Cookbook: Easy solutions to common web development problems with coverage on React, Node.js, and Microservices — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Modern JavaScript Web Development Cookbook: Easy solutions to common web development problems with coverage on React, Node.js, and Microservices" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
How it works...

We have prepared a (hidden) component that responds to orientation changes by dispatching an action to update the store, and we know how to code a component that will use the device information. Our main page could look as follows:

// Source file: src/adaptiveApp/main.js
/* @flow */
import React from "react";
import { View, StatusBar } from "react-native";
import { ConnectedAdaptiveView } from "./adaptiveView.connected";
import { ConnectedDeviceHandler } from "./deviceHandler.connected";
export class Main extends React.PureComponent<> {
render() {
return (
);
}
}

If I run the app on a (simulated) Nexus 5 device in portrait mode, we'd see something like the following:

Our device is recognized as a handset currently in portrait vertical - photo 1

Our device is recognized as a handset, currently in portrait (vertical) orientation

Rotating the device would produce a different view:

When the orientation changes the store is updated and the app re-renders - photo 2

When the orientation changes, the store is updated and the app re-renders itself appropriately

In our design, components never use the Dimension API by themselvessince they get the device information from the store, testing the components' behavior for different devices and orientations could be done functionally, without needing to mock anything.

Using promises instead of error first callbacks

Now, let's start considering several techniques that will come in handy when writing services.

Node runs as a single thread, so if every time it had to call a service, or read a file, or access a database, or do any other I/O-related operation, it would have to wait for it to finish, then attending requests would take a long time, blocking other requests from being attended, and the server would show a very bad performance. Instead, all operations such as those are always done asynchronically, and you must provide a callback that will be called whenever the operation is finished; meanwhile, Node will be available to process other clients' requests.

There are synchronous versions of many functions, but they can only be applied for desktop work, and never for web servers.

Node established a standard that all callbacks should receive two parameters: an error and a result. If the operation failed somehow, the error argument would describe the reason. Otherwise, if the operation had succeeded, the error would be null or undefined (but, in any case, a falsy value) and the result would have the resultant value.

This means that the usual Node code is full of callbacks, and if a callback itself needs another operation, that means yet more callbacks, which themselves may have even more callbacks, resulting in what is called callback hell. Instead of working in this fashion, we want to be able to opt for modern promises, and, fortunately, there is a simple way to do so. Let's see how we can simplify our code by avoiding callbacks.

Testing and Debugging Your Mobile App

In this chapter, we'll be looking into the following recipes:

  • Writing unit tests with Jest
  • Adding snapshot testing
  • Measuring test coverage
  • Using Storybook to preview components
  • Debugging your app with react-native-debugger
  • Debugging in an alternative way with Reactotron
Spreading and joining values

A new operator, ..., lets you expand an array, string, or object, into independent values. This is harder to explain than to show, so let's see some basic examples:

// Source file: src/spread_and_rest.js
let values = [22, 9, 60, 12, 4, 56];
const maxOfValues = Math.max(...values); // 60
const minOfValues = Math.min(...values); // 4

You can also use it to copy arrays or concatenate them:

// Source file: src/spread_and_rest.js
let arr1 = [1, 1, 2, 3];
let arr2 = [13, 21, 34];
let copyOfArr1 = [...arr1]; // a copy of arr1 is created
let fibArray = [0, ...arr1, 5, 8, ...arr2]; // first 10 Fibonacci numbers
If you apply the spread operator to a string, the effect is to separate it into individual characters, much as if you had used .split(); for instance, console.log(..."JS") shows ["J", "S"], so this case isn't particularly interesting.

You can also use it to clone or modify objects; in fact, this is a usage we're going to meet again later, in , Expanding Your Application, mostly when we use Redux:

// Source file: src/spread_and_rest.js
let person = { name: "Juan", age: 24 };
let copyOfPerson = { ...person }; // same data as in the person object
let expandedPerson = { ...person, sister: "Mara" };
// {name: "Juan", age: 24, sister: "Mara"}

This is also useful for writing functions with an undefined number of arguments, avoiding the old style usage of the arguments pseudo-array. Here, instead of splitting an element into many, it joins several distinct elements into a single array. Note, however, that this usage only applies to the last arguments of a function; something such as function many(a, ...several, b, c) wouldn't be allowed:

// Source file: src/spread_and_rest.js
function average(...nums: Array): number {
let sum = 0;
for (let i = 0; i < nums.length; i++) {
sum += nums[i];
}
return sum / nums.length;
};
console.log(average(22, 9, 60, 12, 4, 56)); // 27.166667
If you are wondering why I called arguments a pseudo-array, the reason is because it looks somewhat like an array, but only provides the .length property; see more at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments. In any case, you won't be dealing with it, thanks to the spread operator.
Packt is searching for authors like you

If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.

There's more...

With what we have done here, you may realize that you have all you could need to handle state, for any application size and you would be right! You could set up the general state for your whole application in the App component (remember we mentioned that App would have more responsibilities?) and you would be able to do the following:

  • Pass it down to components by using props
  • Update it in answer to events that the components send

This is a perfectly valid solution, and App.state could have all sorts of data for the whole page. App could handle, for example, calling a web service to get the regions for a given country, storing the results in its state, and passing it to our components so that they can be rendered. In our hardcoded version, RegionsInformationTable had the list of countries (where did it get it from?) and handled the requests for regions (by returning hardcoded data). In reality, as we'll see later in this book, getting this sort of information from a server would be handled differently, and at a higher level: RegionsInformationTable would handle rendering the table and leave data gathering to another part of your solution.

Even if you passed web services handling to App, as your application grows in size, this sort of solution may become unwieldy because of the number of data fields you may have to keep track of. We'll find a better scalable solution for this in ,

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Modern JavaScript Web Development Cookbook: Easy solutions to common web development problems with coverage on React, Node.js, and Microservices»

Look at similar books to Modern JavaScript Web Development Cookbook: Easy solutions to common web development problems with coverage on React, Node.js, and Microservices. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Modern JavaScript Web Development Cookbook: Easy solutions to common web development problems with coverage on React, Node.js, and Microservices»

Discussion, reviews of the book Modern JavaScript Web Development Cookbook: Easy solutions to common web development problems with coverage on React, Node.js, and Microservices and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.