InterfaceISubOptions

Options that can be passed into method SubEvent.subscribe.

interface ISubOptions {
    name?: string;
    onCancel?: (() => void);
    thisArg?: any;
}

Properties

name?: string

Unique subscription name. It helps with diagnosing subscription leaks, via method SubEvent.getStat, and provides additional details during error handling. The name should help identify place in the code where the subscription was created.

onCancel?: (() => void)

Subscription-cancel callback, to be notified on subscription explicit Subscription.cancel call, or when cancelled implicitly via SubEvent.cancelAll.

This is mostly for internal usage, and has no protection against errors, should the handler throw any.

thisArg?: any

Calling / this context for the subscription callback function.

Standard way of passing in context is this way:

event.subscribe(func.bind(this))

With this option you can also do it this way:

event.subscribe(func, {thisArg: this})