This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface User { | |
| readonly id: number; | |
| readonly name: string; | |
| readonly wifeName: string; | |
| readonly parents: ReadonlyArray<string>; | |
| } | |
| const user: User = { | |
| id: 1, | |
| name: "John", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type DeepReadonlyObject<T> = { readonly [K in keyof T]: DeepReadonly<T[K]> }; | |
| type DeepReadonly<T> = T extends (infer E)[][] | |
| ? ReadonlyArray<ReadonlyArray<DeepReadonlyObject<E>>> | |
| : T extends (infer E)[] | |
| ? ReadonlyArray<DeepReadonlyObject<E>> | |
| : T extends object | |
| ? DeepReadonlyObject<T> | |
| : T; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component, OnDestroy, OnInit } from '@angular/core'; | |
| import { Observable, Subscription } from 'rxjs'; | |
| export class RxJSUtil { | |
| static unsubscribe = (subscriptions: Subscription[]) => | |
| subscriptions.forEach(subscription => subscription.unsubscribe()); | |
| } | |
| @Component({ | |
| selector: 'nx-tutorial-root', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class AppComponent implements OnInit, OnDestroy { | |
| @Selector(CustomersState.SelectedCustomer) | |
| private selectedCustomer$: Observable<Customer>; | |
| @Selector(OrdersState.NewOrder) | |
| private newOrder$: Observable<Order>; | |
| private onComponentDestroy$: Subject<void>; | |
| constructor() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getRandomNumber() { | |
| return Math.floor(Math.random() * 100); | |
| } | |
| function isEvenNumber(number: number) { | |
| return number % 2 == 0; | |
| } | |
| function getPerson() { | |
| if (isEvenNumber(getRandomNumber())) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const maybePerson = getPerson(); | |
| if (maybePerson) { | |
| console.log(maybePerson.name); | |
| } | |
| if (maybePerson && maybePerson.name) { | |
| console.log(maybePerson.name.firstName); | |
| console.log(maybePerson.name.lastName); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const maybePerson = getPerson(); | |
| console.log(maybePerson?.name); | |
| console.log(maybePerson?.name?.firstName); | |
| console.log(maybePerson?.name?.lastName); | |
| console.log(maybePerson?.name?.getFullName?.()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Make the following test cases pass | |
| function isPalindrome(phrase) { | |
| const SPACE = " "; | |
| const lowerCharsInPhrase = phrase | |
| .toLowerCase() | |
| .split("") | |
| .filter(char => char !== SPACE); | |
| return lowerCharsInPhrase.join() === lowerCharsInPhrase.reverse().join(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const theme = { | |
| breakpoints: ['30em', '48em', '62em', '80em'], | |
| zIndices: { | |
| hide: -1, | |
| auto: 'auto', | |
| base: 0, | |
| docked: 10, | |
| dropdown: 1000, | |
| sticky: 1100, | |
| banner: 1200, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createSlice, PayloadAction } from '@reduxjs/toolkit'; | |
| import { UserProfileApi, UserSettingsApi } from '@selfplat/api-model'; | |
| import { AppThunk } from '../root.store'; | |
| import { ProfileService } from './profile.service'; | |
| export interface UserState { | |
| profile: UserProfileApi; | |
| settings: UserSettingsApi; | |
| } |