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 Genres = 'comedy' | 'horror'; | |
type Book = { title: string, genre : Genres}; | |
const firstBook = { | |
title : "My first book", | |
genre: 'comedy' | |
} | |
const secondBook:Book = { | |
title : "My fisrt book", |
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 ExtractRouteParams<T extends string> = | |
string extends T | |
? Record<string, string> | |
// Match empty strings | |
: T extends '' | |
? ['Please provide a template'] | |
// Match whitespace | |
: T extends `${infer _Start} ${infer _Rest}` |
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
@Component({ | |
selector: "array-recursive-c", | |
template: ` | |
<ng-container *ngIf="isArrayHere; else showJustItem"> | |
<!-- iterate on the current level of nested array--> | |
<array-recursive-c | |
*ngFor="let item of value" | |
[value]="item" | |
></array-recursive-c> |
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 { MonoTypeOperatorFunction, Observable, Observer, Operator, TeardownLogic } from 'rxjs'; | |
import { delay, take, switchMapTo } from 'rxjs/operators'; | |
// defining operator as class must implement call method | |
class DelayFirstEmmisionOperator<T> implements Operator<T, T> { | |
constructor(private delayInMs:number) { } | |
call(observer: Observer<T>, source: Observable<T>): TeardownLogic { | |
return source.pipe( | |
delay(this.delayInMs), |
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 curry(fn:Function){ | |
return function(...args:any[]){ | |
// fn.length is number of arguments | |
if(args.length >= fn.length){ | |
return fn.apply(null, args); // just call fn | |
} | |
// bind a new function with passed arguments | |
return fn.bind(null, ...args); | |
} | |
} |
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
@Component({ | |
selector: 'app-root', | |
template: ` | |
<h3>Router outlet </h3> | |
<button type="button" (click)="preloadIt('network-demo')">Preload it</button> | |
<button type="button" (click)="preloadIt('network-second')">Preload second</button> | |
<router-outlet></router-outlet> | |
`, | |
styleUrls: ['./app.component.scss'] | |
}) |
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
@Injectable() | |
export class LocalStorageManagerService extends Observable<Map<string, string>> | |
implements OnDestroy { | |
private readonly _entireStorage$:BehaviorSubject<Map<string, string>> | |
= new BehaviorSubject(this._allStorage()); | |
constructor(@Inject(LOCAL_STORAGE) private _localStorage: Storage){ | |
super( subscriber => { |
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
<!-- the only difference is "someInput" --> | |
<some-directive someInput></some-directive> | |
<some-directive></some-directive> |
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
// defining operator as class must implement call method | |
class LogOperator<T> implements Operator<T, T> { | |
constructor(private _additionalMessage?:string) { } | |
call(observer: Observer<T>, source: Observable<T>): TeardownLogic { | |
return source.pipe( | |
tap(val => console.log(`${this._additionalMessage ? this._additionalMessage : 'Logging: '} ${val}`)) | |
).subscribe(observer); | |
} | |
} |
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 interface StoreConfig<T, V extends Action = Action> { | |
initialState?: InitialState<T>; | |
reducerFactory?: ActionReducerFactory<T, V>; | |
metaReducers?: MetaReducer<T, V>[]; | |
} | |
export interface RootStoreConfig<T, V extends Action = Action> | |
extends StoreConfig<T, V> { | |
runtimeChecks?: Partial<RuntimeChecks>; | |
} |
NewerOlder