@rx-angular/cdk
Version:
@rx-angular/cdk is a Component Development Kit for ergonomic and highly performant angular applications. It helps to to build Large scale applications, UI libs, state management, rendering systems and much more. Furthermore the unique way of mixing reacti
91 lines (84 loc) • 3.35 kB
TypeScript
import { Observable, ObservableInput, Subscribable, OperatorFunction } from 'rxjs';
declare const enum RxNotificationKind {
Suspense = "suspense",
Next = "next",
Error = "error",
Complete = "complete"
}
type RxNotificationValue = 'value' | 'hasValue';
interface RxNextNotification<T> {
value: T;
/**
* @deprecated Instead just check if RxNotificationKind is Next
*/
hasValue: boolean;
kind: RxNotificationKind;
error: boolean;
complete: boolean;
}
interface RxSuspenseNotification<T> {
value: T;
/**
* @deprecated Instead just check if RxNotificationKind is Next
*/
hasValue: boolean;
kind: RxNotificationKind.Suspense;
error: false;
complete: false;
}
interface RxErrorNotification<T> {
value: T;
/**
* @deprecated Instead just check if RxNotificationKind is Next
*/
hasValue: boolean;
kind: RxNotificationKind.Error;
error: any;
complete: false;
}
interface RxCompleteNotification<T> {
value: T;
/**
* @deprecated Instead just check if RxNotificationKind is Next
*/
hasValue: boolean;
kind: RxNotificationKind.Complete;
complete: boolean;
error: false;
}
type RxNotification<T> = RxNextNotification<T> | RxSuspenseNotification<T> | RxErrorNotification<T> | RxCompleteNotification<T>;
/**
* @internal
*
* @description
* This factory function returns an object that can be driven imperatively over a `next` method.
* Internally it prepares the incoming values for rendering by turning them into "template notifications",
* an extended `ObservableNotification` object used to determine the respective template for values, errors, completing
* or suspense states.
*
* Internally it handles different edge cases for initial emits. This helps to have or template creation lazy.
* Also it maps any Observable to RxNotifications. These notifications are bound to the view later and handle the
* display of the default template as well as the suspense, error, complete templates.
*/
declare function createTemplateNotifier<U>(): {
values$: Observable<RxNotification<U>>;
next(observable: ObservableInput<U> | U | Subscribable<U>): void;
withInitialSuspense(withInitialSuspense: boolean): void;
};
declare function toRxErrorNotification<T>(error?: any, value?: T): RxErrorNotification<T>;
declare function toRxSuspenseNotification<T>(value?: T): RxSuspenseNotification<T>;
declare function toRxCompleteNotification<T>(value?: T): RxCompleteNotification<T>;
declare function rxMaterialize<T>(): OperatorFunction<T, RxNotification<T>>;
/**
* @internal
*
* A factory function returning an object to handle the process of switching templates by Notification channel.
* You can next a Observable of `RxNotification` multiple times and merge them into the Observable exposed under `trigger$`
*
*/
declare function templateTriggerHandling<T>(): {
trigger$: Observable<RxNotification<T>>;
next(templateName: Observable<RxNotification<T>>): void;
};
export { RxNotificationKind, createTemplateNotifier, rxMaterialize, templateTriggerHandling, toRxCompleteNotification, toRxErrorNotification, toRxSuspenseNotification };
export type { RxCompleteNotification, RxErrorNotification, RxNextNotification, RxNotification, RxNotificationValue, RxSuspenseNotification };