January 2019
Beginner
210 pages
4h 47m
English
We are going to take a look at another popular immutability library. The library is known as Immer, and it can be installed using the following npm command:
npm install immer
Immer allows us to define immutable classes using the readonly access modifier. This means that we can also create instances of our classes using a standard class constructor:
import produce from "immer";class Street { public readonly num: number; public readonly name: string; public constructor(num: number, name: string) { this.num = num; this.name = name; }}class Address { public readonly city: string; public readonly street: Street; public constructor(city: string, street: Street) { this.city = city; this.street = street; }}const address = new Address( ...Read now
Unlock full access