Skip to content

Commit

Permalink
[6.x] TSLint: handle errors in kbn_internal_native_observable types. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
azasypkin committed Jul 12, 2018
1 parent 2df6eed commit b77a3a0
Showing 1 changed file with 82 additions and 86 deletions.
168 changes: 82 additions & 86 deletions src/core/lib/kbn_internal_native_observable/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
/* tslint:disable */

// This adds a symbol type for `Symbol.observable`, which doesn't exist globally
// in TypeScript yet.
declare global {
Expand All @@ -29,111 +29,107 @@ declare global {
// https://github.com/tc39/proposal-observable#api, with the addition of using
// generics to define the type of the `value`.

declare namespace Observable {
interface Subscription {
// Cancels the subscription
unsubscribe(): void;
interface Subscription {
// A boolean value indicating whether the subscription is closed
closed: boolean;

// A boolean value indicating whether the subscription is closed
closed: boolean;
}
// Cancels the subscription
unsubscribe(): void;
}

interface Subscribable<T> {
subscribe(
observerOrNext?: SubscriptionObserver<T> | ((value: T) => void),
error?: (error: any) => void,
complete?: () => void
): Subscription;
}
interface Subscribable<T> {
subscribe(
observerOrNext?: SubscriptionObserver<T> | ((value: T) => void),
error?: (error: any) => void,
complete?: () => void
): Subscription;
}

type ObservableInput<T> = Subscribable<T> | Iterable<T>;
type ObservableInput<T> = Subscribable<T> | Iterable<T>;

interface SubscriptionObserver<T> {
// Sends the next value in the sequence
next(value: T): void;
interface SubscriptionObserver<T> {
// A boolean value indicating whether the subscription is closed
closed: boolean;

// Sends the sequence error
error(errorValue: Error): void;
// Sends the next value in the sequence
next(value: T): void;

// Sends the completion notification
complete(): void;
// Sends the sequence error
error(errorValue: Error): void;

// A boolean value indicating whether the subscription is closed
closed: boolean;
}
// Sends the completion notification
complete(): void;
}

export interface StartObserver<T> {
start(subscription: Subscription): void;
next?(value: T): void;
error?(err: any): void;
complete?(): void;
}
export interface StartObserver<T> {
start(subscription: Subscription): void;
next?(value: T): void;
error?(err: any): void;
complete?(): void;
}

export interface NextObserver<T> {
start?(subscription: Subscription): void;
next(value: T): void;
error?(err: any): void;
complete?(): void;
}
export interface NextObserver<T> {
start?(subscription: Subscription): void;
next(value: T): void;
error?(err: any): void;
complete?(): void;
}

interface ErrorObserver<T> {
start?(subscription: Subscription): void;
next?(value: T): void;
error(err: any): void;
complete?(): void;
}
interface ErrorObserver<T> {
start?(subscription: Subscription): void;
next?(value: T): void;
error(err: any): void;
complete?(): void;
}

interface CompletionObserver<T> {
start?(subscription: Subscription): void;
next?(value: T): void;
error?(err: any): void;
complete(): void;
}
interface CompletionObserver<T> {
start?(subscription: Subscription): void;
next?(value: T): void;
error?(err: any): void;
complete(): void;
}

type PartialObserver<T> =
| StartObserver<T>
| NextObserver<T>
| ErrorObserver<T>
| CompletionObserver<T>;
type PartialObserver<T> =
| StartObserver<T>
| NextObserver<T>
| ErrorObserver<T>
| CompletionObserver<T>;

interface Observer<T> {
// Receives the subscription object when `subscribe` is called
start(subscription: Subscription): void;
interface Observer<T> {
// Receives the subscription object when `subscribe` is called
start(subscription: Subscription): void;

// Receives the next value in the sequence
next(value: T): void;
// Receives the next value in the sequence
next(value: T): void;

// Receives the sequence error
error(errorValue: Error): void;
// Receives the sequence error
error(errorValue: Error): void;

// Receives a completion notification
complete(): void;
}
// Receives a completion notification
complete(): void;
}

type SubscriberFunction<T> = (
observer: SubscriptionObserver<T>
) => void | null | undefined | (() => void) | Subscription;
type SubscriberFunction<T> = (
observer: SubscriptionObserver<T>
) => void | null | undefined | (() => void) | Subscription;

class Observable<T> {
constructor(subscriber: SubscriberFunction<T>);
export class Observable<T> {
public static of<T>(...items: T[]): Observable<T>;
public static from<T>(x: ObservableInput<T>): Observable<T>;

// Subscribes to the sequence with an observer
subscribe(): Subscription;
subscribe(observer: PartialObserver<T>): Subscription;
constructor(subscriber: SubscriberFunction<T>);

// Subscribes to the sequence with callbacks
subscribe(
onNext: (val: T) => void,
onError?: (err: Error) => void,
onComplete?: () => void
): Subscription;
// Subscribes to the sequence with an observer
public subscribe(): Subscription;
public subscribe(observer: PartialObserver<T>): Subscription;

// Returns itself
[Symbol.observable](): Observable<T>;
// Subscribes to the sequence with callbacks
public subscribe(
onNext: (val: T) => void,
onError?: (err: Error) => void,
onComplete?: () => void
): Subscription;

static of<T>(...items: T[]): Observable<T>;
static from<T>(x: ObservableInput<T>): Observable<T>;
}
// Returns itself
public [Symbol.observable](): Observable<T>;
}

export = Observable;

0 comments on commit b77a3a0

Please sign in to comment.