Skip to content

Instantly share code, notes, and snippets.

View vs-borodin's full-sized avatar
🎯
Focusing

Vyacheslav Borodin vs-borodin

🎯
Focusing
View GitHub Profile
@vs-borodin
vs-borodin / debounced.ts
Created December 20, 2025 21:01
debounced
import {
assertInInjectionContext,
assertNotInReactiveContext,
inject,
INJECTOR,
type Injector,
type Signal,
} from '@angular/core';
import { toObservable, toSignal } from '@angular/core/rxjs-interop';
import { debounceTime } from 'rxjs';
@vs-borodin
vs-borodin / teleport.ts
Last active December 9, 2025 17:13
teleport.ts
import { afterRenderEffect, DestroyRef, Directive, ElementRef, inject, input } from '@angular/core';
@Directive({ selector: 'ng-teleport' })
export class Teleport {
private readonly destroyRef = inject(DestroyRef);
private readonly el: HTMLElement /* https://github.com/angular/angular/issues/53894 */ = inject(
ElementRef<HTMLElement>
).nativeElement;
readonly to = input.required<string>();
@vs-borodin
vs-borodin / inject-cva.ts
Last active December 21, 2025 18:37
injectCva
import {
afterNextRender,
type AfterRenderRef,
assertInInjectionContext,
assertNotInReactiveContext,
type CreateEffectOptions,
effect,
type EffectCleanupRegisterFn,
type EffectRef,
inject,