ngrx-rtk-query
Version:
Angular RTK Query
28 lines (27 loc) • 981 B
TypeScript
/**
* The code in this file is adapted from TanStack/query
*
* TanStack/query is an open-source project licensed under the MIT license.
*
* For more information about the original code, see
* https://github.com/TanStack/query
*/
import { type Signal as NgSignal } from '@angular/core';
export interface Signal<T> extends NgSignal<T> {
name: unknown;
length: unknown;
}
export type SignalsMap<T> = Required<{
[K in keyof T]: T[K] extends Function ? T[K] : Signal<T[K]>;
}>;
export type DeepSignal<T> = Signal<T> & SignalsMap<T>;
/**
* Exposes fields of an object passed via an Angular `Signal` as `Computed` signals.
*
* Functions on the object are passed through as-is.
*
* @param signal - `Signal` that must return an object.
*
*/
export declare function signalProxy<T extends Record<string | symbol, any>>(signal: Signal<T>): SignalsMap<T>;
export declare function toDeepSignal<T extends Record<string | symbol, any>>(signal: Signal<T>): DeepSignal<T>;