| 1 |
## API Report File for "@lumino/polling" |
| 2 |
|
| 3 |
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). |
| 4 |
|
| 5 |
```ts |
| 6 |
|
| 7 |
import { IDisposable } from '@lumino/disposable'; |
| 8 |
import { IObservableDisposable } from '@lumino/disposable'; |
| 9 |
import { ISignal } from '@lumino/signaling'; |
| 10 |
import { PromiseDelegate } from '@lumino/coreutils'; |
| 11 |
|
| 12 |
// @public |
| 13 |
export class Debouncer<T = any, U = any, V extends any[] = any[]> extends RateLimiter<T, U, V> { |
| 14 |
invoke(...args: V): Promise<T>; |
| 15 |
} |
| 16 |
|
| 17 |
// @public |
| 18 |
export interface IPoll<T, U, V extends string> extends AsyncIterable<IPoll.State<T, U, V>> { |
| 19 |
readonly disposed: ISignal<this, void>; |
| 20 |
readonly frequency: IPoll.Frequency; |
| 21 |
readonly isDisposed: boolean; |
| 22 |
readonly name: string; |
| 23 |
readonly state: IPoll.State<T, U, V>; |
| 24 |
readonly tick: Promise<IPoll<T, U, V>>; |
| 25 |
readonly ticked: ISignal<IPoll<T, U, V>, IPoll.State<T, U, V>>; |
| 26 |
} |
| 27 |
|
| 28 |
// @public |
| 29 |
export namespace IPoll { |
| 30 |
export type Frequency = { |
| 31 |
readonly backoff: boolean | number; |
| 32 |
readonly interval: number; |
| 33 |
readonly max: number; |
| 34 |
}; |
| 35 |
export type Phase<T extends string> = T | 'constructed' | 'disposed' | 'reconnected' | 'refreshed' | 'rejected' | 'resolved' | 'standby' | 'started' | 'stopped'; |
| 36 |
export type State<T, U, V extends string> = { |
| 37 |
readonly interval: number; |
| 38 |
readonly payload: T | U | null; |
| 39 |
readonly phase: Phase<V>; |
| 40 |
readonly timestamp: number; |
| 41 |
}; |
| 42 |
} |
| 43 |
|
| 44 |
// @public |
| 45 |
export interface IRateLimiter<T = any, U = any, V extends any[] = any[]> extends IDisposable { |
| 46 |
invoke(...args: V): Promise<T>; |
| 47 |
readonly limit: number; |
| 48 |
stop(): Promise<void>; |
| 49 |
} |
| 50 |
|
| 51 |
// @public |
| 52 |
export class Poll<T = any, U = any, V extends string = 'standby'> implements IObservableDisposable, IPoll<T, U, V> { |
| 53 |
[Symbol.asyncIterator](): AsyncIterableIterator<IPoll.State<T, U, V>>; |
| 54 |
constructor(options: Poll.IOptions<T, U, V>); |
| 55 |
dispose(): void; |
| 56 |
get disposed(): ISignal<this, void>; |
| 57 |
get frequency(): IPoll.Frequency; |
| 58 |
set frequency(frequency: IPoll.Frequency); |
| 59 |
protected get hidden(): boolean; |
| 60 |
get isDisposed(): boolean; |
| 61 |
readonly name: string; |
| 62 |
refresh(): Promise<void>; |
| 63 |
schedule(next?: Partial<IPoll.State<T, U, V> & { |
| 64 |
cancel: (last: IPoll.State<T, U, V>) => boolean; |
| 65 |
}>): Promise<void>; |
| 66 |
get standby(): Poll.Standby | (() => boolean | Poll.Standby); |
| 67 |
set standby(standby: Poll.Standby | (() => boolean | Poll.Standby)); |
| 68 |
start(): Promise<void>; |
| 69 |
get state(): IPoll.State<T, U, V>; |
| 70 |
stop(): Promise<void>; |
| 71 |
get tick(): Promise<this>; |
| 72 |
get ticked(): ISignal<this, IPoll.State<T, U, V>>; |
| 73 |
} |
| 74 |
|
| 75 |
// @public |
| 76 |
export namespace Poll { |
| 77 |
export type Factory<T, U, V extends string> = (state: IPoll.State<T, U, V>) => Promise<T>; |
| 78 |
export interface IOptions<T, U, V extends string> { |
| 79 |
auto?: boolean; |
| 80 |
factory: Factory<T, U, V>; |
| 81 |
frequency?: Partial<IPoll.Frequency>; |
| 82 |
linger?: number; |
| 83 |
name?: string; |
| 84 |
standby?: Standby | (() => boolean | Standby); |
| 85 |
} |
| 86 |
export type Standby = 'never' | 'when-hidden'; |
| 87 |
const IMMEDIATE = 0; |
| 88 |
const MAX_INTERVAL = 2147483647; |
| 89 |
const NEVER: number; |
| 90 |
} |
| 91 |
|
| 92 |
// @public |
| 93 |
export abstract class RateLimiter<T, U, V extends any[]> implements IRateLimiter<T, U, V> { |
| 94 |
constructor(fn: (...args: V) => T | Promise<T>, limit?: number); |
| 95 |
protected args: V | undefined; |
| 96 |
dispose(): void; |
| 97 |
abstract invoke(...args: V): Promise<T>; |
| 98 |
get isDisposed(): boolean; |
| 99 |
readonly limit: number; |
| 100 |
protected payload: PromiseDelegate<T> | null; |
| 101 |
protected poll: Poll<T, U, 'invoked'>; |
| 102 |
stop(): Promise<void>; |
| 103 |
} |
| 104 |
|
| 105 |
// @public |
| 106 |
export class Throttler<T = any, U = any, V extends any[] = any[]> extends RateLimiter<T, U, V> { |
| 107 |
constructor(fn: (...args: V) => T | Promise<T>, options?: Throttler.IOptions | number); |
| 108 |
invoke(...args: V): Promise<T>; |
| 109 |
} |
| 110 |
|
| 111 |
// @public |
| 112 |
export namespace Throttler { |
| 113 |
export interface IOptions { |
| 114 |
edge?: 'leading' | 'trailing'; |
| 115 |
limit?: number; |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
``` |