• Complain

Lars Gyrup Brink Nielsen - Accelerating Angular Development with Ivy: A practical guide to building faster and more testable Angular apps with the new Ivy engine

Here you can read online Lars Gyrup Brink Nielsen - Accelerating Angular Development with Ivy: A practical guide to building faster and more testable Angular apps with the new Ivy engine full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2021, 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.

Lars Gyrup Brink Nielsen Accelerating Angular Development with Ivy: A practical guide to building faster and more testable Angular apps with the new Ivy engine
  • Book:
    Accelerating Angular Development with Ivy: A practical guide to building faster and more testable Angular apps with the new Ivy engine
  • Author:
  • Publisher:
    Packt Publishing
  • Genre:
  • Year:
    2021
  • Rating:
    5 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 100
    • 1
    • 2
    • 3
    • 4
    • 5

Accelerating Angular Development with Ivy: A practical guide to building faster and more testable Angular apps with the new Ivy engine: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Accelerating Angular Development with Ivy: A practical guide to building faster and more testable Angular apps with the new Ivy engine" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Get a comprehensive introduction to the major Angular framework rewrite known as Angular Ivy

Key Features
  • Upgrade your Angular applications from traditional View Engine to modern Angular Ivy
  • Get a detailed walkthrough of the new features and breaking changes in Angular
  • Explorer new Angular APIs, syntax, tooling, and configurations for modern frontend web development
Book Description

Angular Ivy is the latest rendering engine and compiler introduced in Angular. Ivy helps frontend developers to make their Angular applications faster, better optimized, and more robust. This easy-to-follow guide will help you get to grips with the new features of Angular Ivy and show you how to migrate your Angular apps from View Engine to Ivy.

Youll begin by learning about the most popular features of Angular Ivy with the help of simple stand-alone examples and realize its capabilities by working on a real-world application project. Youll then discover strategies to improve your developer workflow through new debugging APIs, testing APIs, and configurations that support higher code quality and productive development features. Throughout the book, youll explore essential components of Angular, such as Angular Component Dev Kit (CDK), Ahead-of-time (AOT) compilation, and Angular command line interface (CLI). Finally, youll gain a clear understanding of these components along with Angular Ivy which will help you update your Angular applications with modern features.

By the end of this Angular Ivy book, you will learn about the core features of Angular Ivy, discover how to migrate your Angular View Engine application, and find out how to set up a high-quality Angular Ivy project.

What you will learn
  • Find out why Angular Ivy tests are faster and more robust
  • Explore the concept of CSS custom properties and scoping of values and learn how to use them with Angular Ivy
  • Use testing harnesses present in Angular components to write effective tests
  • Explore the architecture of the Angular compatibility compiler and understand why it is important
  • Discover effective techniques for migrating your existing Angular apps to the Ivy engine
  • Overcome challenges that you might face when switching to AOT compilation
Who this book is for

This book is for experienced Angular web developers who want to migrate to the latest Ivy engine for building faster web applications. Intermediate knowledge of Angular and TypeScript will help you get the most out of this book.

Table of Contents
  1. Discovering New APIs and Language Syntax
  2. Boosting Developer Productivity Through Tooling, Configuration, and Convenience
  3. Introducing CSS Custom Properties and New Provider Scopes
  4. Exploring Angular Components Features
  5. Using CSS Custom Properties
  6. Using Angular Components
  7. Component Harnesses
  8. Additional Provider Scopes
  9. Debugging with the New Ivy Runtime APIs
  10. Using the Angular Compatibility Compiler
  11. Migrating your Angular Application from View Engine to Ivy
  12. Embracing Ahead-of-Time Compilation

Lars Gyrup Brink Nielsen: author's other books


Who wrote Accelerating Angular Development with Ivy: A practical guide to building faster and more testable Angular apps with the new Ivy engine? Find out the surname, the name of the author of the book and a list of all author's works by series.

Accelerating Angular Development with Ivy: A practical guide to building faster and more testable Angular apps with the new Ivy engine — 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 "Accelerating Angular Development with Ivy: A practical guide to building faster and more testable Angular apps with the new Ivy engine" 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
Chapter 1 Discovering New APIs and Language Syntax As its only officially - photo 1
Chapter 1: Discovering New APIs and Language Syntax

As its only officially supported programming language, Angular is tightly coupled with TypeScript. Support for new versions of TypeScript is introduced with major and minor version releases of Angular. In this chapter, we will explore three powerful language features that have been released in the recent versions of TypeScript and Angular:

  • The optional chaining operator (?.)
  • The nullish coalescing operator (??)
  • Native private class members (#)

Through simple examples, we will highlight the strengths of these modern programming language features. We will even learn how two of the new operators work elegantly together in common scenarios. Learning about this new syntax and semantics is key to understanding the examples throughout this book.

Globalization is the process of supporting and adapting multilingual and regional capabilities in an application. Angular Ivy introduces improved globalization APIs. Together, we will learn about localization bundling, directionality querying, and lazy loading locale data through comprehensive examples.

Many core parts of Angular are built with testability in mind. Angular Ivy introduces strongly typed dependency resolving in tests and a fake icon registry for integrated component tests.

In this first chapter, we will cover the following topics:

  • Modernizing your code with powerful language features
  • Optimizing regional support with improved globalization APIs
  • Enhancing tests with stronger types and new APIs

The demo application featured in Part 2, Build a Real-World Application with the Angular Ivy Features You Learned does not use globalization APIs. The tests featured in that part focus on component testing using the new concept component testing harnesses, which will be introduced in , Introducing CSS Custom Properties and New Provider Scopes.

After reading this chapter, you will be able to refactor your existing Angular applications and tests to use modern standards and Angular APIs when developing.

Technical requirements

To support all the features introduced in this chapter, your application requires at least the following:

  • Angular Ivy version 9.1
  • TypeScript version 3.8

You can find the complete code examples for the globalization APIs in this book's companion GitHub repository at https://github.com/PacktPublishing/Accelerating-Angular-Development-with-Ivy/tree/main/projects/chapter1/globalization.

Modernizing your code with powerful language features

TypeScript is an integral part of Angular, but because Angular has its own compiler transformations that extend TypeScript's compilation steps, we are inevitably tied to the version of TypeScript that the Angular compiler supports. Fortunately, Angular is good at keeping up with recent versions of TypeScript. In this section, we are going to discuss some of the most noteworthy additions to the TypeScript language in the most recent versions supported by Angular Ivy.

The optional chaining operator

TypeScript version 3.7 introduces a new operator for optional property access, optional element access, and optional calls. The optional chaining operator (?.) short circuits in the case of nullish values that is, null or undefined in which case it evaluates to undefined.

Optional chaining is great for working with composite objects or just plain old complex data structures such as large business documents transferred from a server, a dynamic runtime configuration, or telemetry from Internet of Things (IoT) devices.

The optional chaining operator allows us to be more concise in a single expression that attempts to access a hierarchy of properties that may or may not be available.

Say we are working on a document processing system that supports Universal Business Language (UBL) documents in JSON format. In our UBL invoice parser, we want to determine the UBL version that the document follows to be able to parse it according to a standard version. We fall back to UBL version 2.1 if it's left unspecified.

Without optional chaining, our code might look like this, given an invoice variable containing the invoice document:

const ublVersion =

(invoice.Invoice[0].UBLVersionID &&

invoice.Invoice[0].UBLVersionID[0] &&

invoice.Invoice[0].UBLVersionID[0].IdentifierContent) || '2.1';

For each optional property or array element in the invoice data structure, we must make a conditional check to break the circuit; otherwise, we will end up trying to access a property of an undefined value, which will result in a runtime error.

With the optional chaining operator, our statement is simplified to the following one:

const ublVersion =

invoice.Invoice[0].UBLVersionID?.[0]?.IdentifierContent || '2.1';

Now, we can see the structure of the document and identify every optional property or array element as they are succeeded by the optional chaining operator, ?..

The noise of conditional access is reduced to a bare minimum. At the same time, the risk of a mistake occurring is reduced as it is less code overall and there is no repeated code, meaning that we would only have to make a single change in our code if the shape of the data structure changed.

In the invoice document examples in the previous two code listings, we have seen the optional chaining operator being used for optional property and element access.

Important Note

Optional access using strings and symbols is also supported. Even optional access using computed property names is supported.

The last use case for this new operator is optional function or method calls. Let's go through an example.

Let's say we follow a classical API style of allowing our consumers to pass success and error callbacks. If the error callback is optional, we must check that it was passed before calling it; otherwise, we will get a runtime error.

In the catch clause of the following code, we can see a conditional call for the onError callback:

function parseDocument(

json: string,

onSuccess: (document: UBLDocument) => void,

onError?: (error: Error) => void

): void {

try {

const document = JSON.parse(json);

onSuccess(document);

} catch (error) {

if (onError) {

onError(error);

}

}

}

With the optional chaining operator, we can simplify the conditional function call as seen in the following code:

function parseDocument(

json: string,

onSuccess: (document: UBLDocument) => void,

onError?: (error: Error) => void

): void {

try {

const document = JSON.parse(json);

onSuccess(document);

} catch (error) {

onError?.(error);

}

}

Even though a function is not a member of an object, we can still use an optional call to invoke it conditionally. We put the optional chaining operator between the function name and the parentheses that wrap the arguments passed to it, as seen in the previous code.

Keep in mind that the optional chaining operator returns undefined when the conditional property it guards contains a nullish value. This means that an expression that involves optional chaining can only return

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Accelerating Angular Development with Ivy: A practical guide to building faster and more testable Angular apps with the new Ivy engine»

Look at similar books to Accelerating Angular Development with Ivy: A practical guide to building faster and more testable Angular apps with the new Ivy engine. 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 «Accelerating Angular Development with Ivy: A practical guide to building faster and more testable Angular apps with the new Ivy engine»

Discussion, reviews of the book Accelerating Angular Development with Ivy: A practical guide to building faster and more testable Angular apps with the new Ivy engine 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.