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
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |
export interface CachedDecoratorOptions<FunctionArguments extends any[]> { | |
keyGenerator?: CacheKeyGenerator<FunctionArguments>; | |
cache?: CacheFactory; | |
} | |
export type CacheKeyGenerator<T extends any[]> = (...args: T) => unknown; // eslint-disable-line @typescript-eslint/no-explicit-any | |
export interface Cache { | |
get(cacheKey: unknown): unknown; |
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 { Subscription } from 'rxjs'; | |
const GLOBAL_COMPONENT_SUBSCRIPTIONS = new WeakMap<any, Set<Subscription>>(); | |
export function NgInit< | |
TargetType extends { constructor: Function, ngOnInit?(): void, ngOnDestroy?(): void }, | |
PropertyKey extends string, | |
PropertyContainer extends { [k in PropertyKey]: () => (void | Subscription) }, | |
FunctionType extends PropertyContainer[PropertyKey] | |
>( |
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 GLOBAL_MEMOIZATION_MAP = new WeakMap<object, Map<string, unknown>>(); | |
// tslint:disable-next-line:ban-types | |
export function Memoize<T extends { constructor: Function }>( | |
target: T, | |
propertyKey: string, | |
descriptor: PropertyDescriptor, | |
): PropertyDescriptor { | |
const originalGet = descriptor.get; // tslint:disable-line: no-unbound-method |
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 TRANSLATION_KEY_PLACEHOLDER = Symbol('TRANSLATION_KEY_PLACEHOLDER'); | |
type TranslationKeyPlaceholder = typeof TRANSLATION_KEY_PLACEHOLDER; | |
export interface TranslationStructure { | |
[key: string]: TranslationStructure | TranslationKeyPlaceholder; | |
} | |
export type TranslationKeysOf<T extends TranslationStructure> = { | |
[P in keyof T]: T[P] extends TranslationStructure ? TranslationKeysOf<T[P]> : string | |
}; |
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
// ======================================== | |
// app-module.ts | |
// ======================================== | |
import { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule } from '@angular/core'; | |
import { AppComponent } from './app.component'; | |
import { NumbersModule } from './numbers'; | |
@NgModule({ |
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 { BehaviorSubject, Observable } from 'rxjs'; | |
/** | |
* Observes the specified property and returns a stream that emits all values which are assigned to the property. When subscribing to the | |
* resulting stream it will always first emit the current value of the property, followed by all new values that are assigned to it. | |
* | |
* @param target Object containing the property. | |
* @param key Key of the property that is to be observed. | |
* @returns A stream of all values that are assigned to the specified property, starting with the current value of the property. | |
*/ |