UNPKG

@onesy/subscription

Version:
39 lines (38 loc) 1.07 kB
import { TMethod } from '@onesy/models'; export interface ISubscribe { unsubscribe: () => void; } export interface IOptions { emit?: { priorValue?: boolean; copy?: boolean; pre?: { method?: TMethod; }; post?: { method?: TMethod; }; }; } export interface IOnesySubscription<T> { methods: Array<TMethod>; emit(value: T, ...other: any[]): void; push(value: T, ...other: any[]): void; subscribe(method: TMethod): void; unsubscribe(method: TMethod): void; [p: string]: any; } declare class OnesySubscription<T = any> implements IOnesySubscription<T> { value?: T; options: IOptions; methods: Array<TMethod>; constructor(value?: T, options?: IOptions); get length(): number; emit(value: T, ...other: any[]): void; push: (value: T, ...other: any[]) => void; forEach(...args: any[]): void; map(value_?: any): any; subscribe(method: TMethod): ISubscribe; unsubscribe(method: TMethod): void; } export default OnesySubscription;