import { WritableSignal } from '@angular/core'; import { BehaviorSubject, Observable, Subscription } from 'rxjs'; import { Destroyable } from './mixins'; /** * A piece of reactive state. The changes can be subscribed to, and built upon. * Similar to a BehaviorSubject but: * - the source of new values can be changed while retaining the local value and downstream subscriptions * - it's easy to unsubscribe upstream/downstream when the component is destroyed * @deprecated */ export declare class State { $: BehaviorSubject; source: Observable; subscription: Subscription; private _value; _until: Observable; constructor(defaultValue: T, until?: any, source?: any); get value(): T; set value(value: T); changed(): void; /** * Sets the source of new values * @param source An observable providing the new values or a plain value */ subscribeSource(source: any): void; /** * * @param until An observable. */ until(until: Observable): void; private _unsubscribeSource; } /** * Listen for changes on an object property * @example * class MyComponent { * text = '' * constructor() { * onChange(this, 'text', value => { * console.log(`called when text changes`) * }) * } * } */ export declare function onChange(object: C, key: K, func: (value: C[K]) => void, transformValue?: (value: any, oldValue: any) => any | undefined): void; /** * Listens for changes on a property and exposes it as an Observable. * Replaces the property with a getter/setter so it can detect changes. * * Example: listens for a property `text` and creates an Observable `$text`. * ```ts * this.text = 'blabla' * this.$text = new BehaviorSubject(null) * makeObservable(this, 'text', '$text') * ``` */ export declare function makeObservable(_component: T, key: K, observableKey: K): void; /** * Listens for changes on a property and exposes it as a Signal. * Replaces the property with a getter/setter so it can detect changes. * * Example: listens for a property `text` and creates a Signal `$text`. * ```ts * this.text = 'blabla' * this.$text = signal(null) * makeSignal(this, 'text', '$text') * ``` */ export declare function makeSignal(_component: T, key: K, signalKey: K): void; export declare function inputSignal(_component: T, key: K): void; /** * Subscribes to an observable for the lifetime of the component. * @param component The subscription gets cleaned up when this component gets destroyed. * @param observable The observable to subscribe to. * @param func A function that gets called whenever the observable changes. */ export declare function subscribe(component: Destroyable, observable: Observable, func: (value: T) => void): Subscription; /** * Subscribes to an observable and makes it into a property of the component. * Unsubscribes when the component gets destroyed. * @param component The subscription gets cleaned up when this component gets destroyed. * @param observable The observable to subscribe to. * @param key Name of the property that gets updated when the observable changes. */ export declare function makeProperty(component: Destroyable & T, observable: Observable, key: K): void; export declare function derived(computation: () => R, updateSource: (value: W) => void): WritableSignal; /** * @example * class MyComponent { * text = '' * constructor() { * makeIntoSignal(this, 'text') * } * } */ export declare function makeIntoSignal(object: C, ...keys: K[]): void; export declare function forceRefresh(): void; export declare function propToSignal(component: T, key: K): void;