This file contains 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 { fromEvent, Subject, Observable, OperatorFunction, merge } from 'rxjs'; | |
import { take, takeUntil, filter, map } from 'rxjs/operators'; | |
interface OAuthData { | |
source: string; | |
success: boolean; | |
listingSourceId?: string; | |
} | |
type OAuthEvent = Event & { data?: OAuthData; origin: string }; |
This file contains 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 { Observable, EMPTY } from 'rxjs'; | |
import { expand, reduce } from 'rxjs/operators'; | |
export type Request<T> = (pageNumber: number, response?: T) => Observable<T>; | |
export type HasMore<T> = (response: T, pageNumber: number) => boolean; | |
export type JoinResults<T> = (accumulator: T, response: T) => T; | |
export interface Config<T> { | |
/** |
This file contains 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 { Injectable } from '@angular/core'; | |
import { ActionSheetController, Platform } from '@ionic/angular'; | |
import { AppService } from './app.service'; | |
import { Camera } from '@ionic-native/camera/ngx'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class GetPhotoService { |
This file contains 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
/** | |
* Returns duration in ms from ISO 8601 string. | |
* E.g. "PT15M33S" is converted to 933000 | |
*/ | |
export function convertISO8601ToMs(duration: string): number { | |
const time_extractor = /^P([0-9]*D)?T([0-9]*H)?([0-9]*M)?([0-9]*S)?$/i; | |
const extracted = time_extractor.exec(duration); | |
if (extracted) { | |
const days = parseInt(extracted[1], 10) || 0; | |
const hours = parseInt(extracted[2], 10) || 0; |
This file contains 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
/** | |
* Hypertext Transfer Protocol (HTTP) response status codes. | |
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes} | |
*/ | |
export enum HttpStatusCodesEnum { | |
/** No internet connection */ | |
NO_INTERNET_CONNECTION = 0, | |
/** | |
* The server has received the request headers and the client should proceed to send the request body |
This file contains 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 { ChangeDetectionStrategy, ChangeDetectorRef, Component, forwardRef } from '@angular/core'; | |
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; | |
const COUNTER_CONTROL_ACCESSOR = { | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: forwardRef(() => CounterControlComponent), | |
multi: true, | |
}; | |
@Component({ |
This file contains 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 { | |
readonly animal = new FormControl(‘rabbit’); | |
constructor() { | |
ctrl.valueChanges.subscribe(console.log); | |
animal.setValue(‘hare’); | |
animal.setValue(‘cat’); | |
} | |
} |
This file contains 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
// ... code of CounterComponent | |
writeValue(value: number) { | |
// it's convenient to reuse existing "setValue" method, right? | |
// however, this will lead to the incorrect behavior | |
this.setValue(value); | |
this._cdr.markForCheck(); | |
} | |
protected setValue(value: number) { | |
const parsed = parseInt(value as any); |
This file contains 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 ControlValueAccessor { | |
writeValue(obj: any): void | |
registerOnChange(fn: any): void | |
registerOnTouched(fn: any): void | |
setDisabledState(isDisabled: boolean)?: void | |
} |
This file contains 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
// ... code of CounterComponent | |
writeValue(value: number) { | |
// it's convenient to reuse existing "setValue" method, right? | |
// however, this will lead to the incorrect behavior | |
this.setValue(value, false); | |
this._cdr.markForCheck(); | |
} | |
protected setValue(value: number, emitEvent: boolean) { | |
this.value = value; |
OlderNewer