Skip to main content

Class: AdaptiveNearestSubscription<InnerType>

A wrapper for a NearestSearchSession that automatically adjusts the number of search results requested from the sim to minimize search load while still attempting to provide the total number of results needed by the user.

Type parameters

NameType
InnerTypeextends NearestSubscription<any>

Hierarchy

Implements

Constructors

constructor

new AdaptiveNearestSubscription<InnerType>(innerSubscription, absoluteMaxItems): AdaptiveNearestSubscription<InnerType>

Creates an instance of AdaptiveNearestSubscription.

Type parameters

NameType
InnerTypeextends NearestSubscription<any>

Parameters

NameTypeDescription
innerSubscriptionInnerTypeA NearestSubscription to use as our inner search.
absoluteMaxItemsnumber | Subscribable<number>The maximum number of results to request in any search.

Returns

AdaptiveNearestSubscription<InnerType>

Overrides

AbstractSubscribableArray.constructor

Defined in

src/sdk/navigation/NearestSubscription.ts:551

Properties

initialNotifyFunc

Protected Readonly initialNotifyFunc: (sub: HandlerSubscription<SubscribableArrayHandler<NearestSubscriptionFacilityType<InnerType>>>) => void

A function which sends initial notifications to subscriptions.

Type declaration

▸ (sub): void

A function which sends initial notifications to subscriptions.

Parameters
NameType
subHandlerSubscription<SubscribableArrayHandler<NearestSubscriptionFacilityType<InnerType>>>
Returns

void

Inherited from

AbstractSubscribableArray.initialNotifyFunc

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:20


innerSubscription

Readonly innerSubscription: InnerType

A NearestSubscription to use as our inner search.

Defined in

src/sdk/navigation/NearestSubscription.ts:551


notifyDepth

Protected notifyDepth: number = 0

Inherited from

AbstractSubscribableArray.notifyDepth

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:17


onSubDestroyedFunc

Protected Readonly onSubDestroyedFunc: (sub: HandlerSubscription<SubscribableArrayHandler<NearestSubscriptionFacilityType<InnerType>>>) => void

A function which responds to when a subscription to this subscribable is destroyed.

Type declaration

▸ (sub): void

A function which responds to when a subscription to this subscribable is destroyed.

Parameters
NameType
subHandlerSubscription<SubscribableArrayHandler<NearestSubscriptionFacilityType<InnerType>>>
Returns

void

Inherited from

AbstractSubscribableArray.onSubDestroyedFunc

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:23


singletonSub

Protected Optional singletonSub: HandlerSubscription<SubscribableArrayHandler<NearestSubscriptionFacilityType<InnerType>>>

Inherited from

AbstractSubscribableArray.singletonSub

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:14


subs

Protected Optional subs: HandlerSubscription<SubscribableArrayHandler<NearestSubscriptionFacilityType<InnerType>>>[]

Inherited from

AbstractSubscribableArray.subs

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:16

Accessors

length

get length(): number

The length of this array.

Returns

number

Implementation of

NearestSubscription.length

Overrides

AbstractSubscribableArray.length

Defined in

src/sdk/navigation/NearestSubscription.ts:558


started

get started(): boolean

Whether this search has started.

Returns

boolean

Implementation of

NearestSubscription.started

Defined in

src/sdk/navigation/NearestSubscription.ts:568

Methods

addSubscription

addSubscription(sub): void

Adds a subscription to this array.

Parameters

NameTypeDescription
subHandlerSubscription<SubscribableArrayHandler<NearestSubscriptionFacilityType<InnerType>>>The subscription to add.

Returns

void

Inherited from

AbstractSubscribableArray.addSubscription

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:29


awaitStart

awaitStart(): Promise<void>

Waits until this search has started.

Returns

Promise<void>

Implementation of

NearestSubscription.awaitStart

Defined in

src/sdk/navigation/NearestSubscription.ts:573


get

get(index): NearestSubscriptionFacilityType<InnerType>

Gets an item from the array.

Parameters

NameTypeDescription
indexnumberThex index of the item to get.

Returns

NearestSubscriptionFacilityType<InnerType>

An item.

Throws

Implementation of

NearestSubscription.get

Inherited from

AbstractSubscribableArray.get

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:77


getArray

getArray(): readonly NearestSubscriptionFacilityType<InnerType>[]

Gets a read-only version of this array.

Returns

readonly NearestSubscriptionFacilityType<InnerType>[]

a read-only version of this array.

Implementation of

NearestSubscription.getArray

Overrides

AbstractSubscribableArray.getArray

Defined in

src/sdk/navigation/NearestSubscription.ts:563


initialNotify

initialNotify(sub): void

Notifies a subscription of this array's current state.

Parameters

NameTypeDescription
subHandlerSubscription<SubscribableArrayHandler<NearestSubscriptionFacilityType<InnerType>>>The subscription to notify.

Returns

void

Inherited from

AbstractSubscribableArray.initialNotify

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:176


notify

notify(index, type, modifiedItem?): void

Notifies subscriptions of a change in the array.

Parameters

NameTypeDescription
indexnumberThe index that was changed.
typeSubscribableArrayEventTypeThe type of subject event.
modifiedItem?NearestSubscriptionFacilityType<InnerType> | readonly NearestSubscriptionFacilityType<InnerType>[]The item modified by the operation.

Returns

void

Inherited from

AbstractSubscribableArray.notify

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:100


onSubDestroyed

onSubDestroyed(sub): void

Responds to when a subscription to this array is destroyed.

Parameters

NameTypeDescription
subHandlerSubscription<SubscribableArrayHandler<NearestSubscriptionFacilityType<InnerType>>>The destroyed subscription.

Returns

void

Inherited from

AbstractSubscribableArray.onSubDestroyed

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:185


start

start(): Promise<void>

Starts this search.

Returns

Promise<void>

Implementation of

NearestSubscription.start

Defined in

src/sdk/navigation/NearestSubscription.ts:578


sub

sub(handler, initialNotify?, paused?): Subscription

Subscribes to changes in this array's state.

Parameters

NameTypeDefault valueDescription
handlerSubscribableArrayHandler<NearestSubscriptionFacilityType<InnerType>>undefinedA function which is called when this array's state changes.
initialNotifybooleanfalseWhether to immediately invoke the callback function with this array's current state. Defaults to false. This argument is ignored if the subscription is initialized as paused.
pausedbooleanfalseWhether the new subscription should be initialized as paused. Defaults to false.

Returns

Subscription

The new subscription.

Implementation of

NearestSubscription.sub

Inherited from

AbstractSubscribableArray.sub

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:41


tryGet

tryGet(index): undefined | NearestSubscriptionFacilityType<InnerType>

Tries to get the value from the array.

Parameters

NameTypeDescription
indexnumberThe index of the item to get.

Returns

undefined | NearestSubscriptionFacilityType<InnerType>

The value or undefined if not found.

Implementation of

NearestSubscription.tryGet

Inherited from

AbstractSubscribableArray.tryGet

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:90


unsub

unsub(handler): void

Unsubscribes a callback function from this array.

Parameters

NameTypeDescription
handlerSubscribableArrayHandler<NearestSubscriptionFacilityType<InnerType>>The function to unsubscribe.

Returns

void

Deprecated

This method has been deprecated in favor of using the Subscription object returned by .sub() to manage subscriptions.

Implementation of

NearestSubscription.unsub

Inherited from

AbstractSubscribableArray.unsub

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:56


update

update(lat, lon, radius, maxItems): Promise<void>

Updates this search with new parameters. If an update is already in progress, this method will wait until the existing update is finished and then fulfill its returned Promise immediately.

Parameters

NameTypeDescription
latnumberThe latitude, in degrees, of the center of the search.
lonnumberThe longitude, in degrees, of the center of the search.
radiusnumberThe radius of the search, in meters.
maxItemsnumberThe maximum number of items to return from the search.

Returns

Promise<void>

A Promise which will be fulfilled when the update is complete.

Implementation of

NearestSubscription.update

Defined in

src/sdk/navigation/NearestSubscription.ts:583