Class: AbstractNearestSubscription<T, TAdded, TRemoved>
A class for tracking a nearest facility session and making it available as a subscribable array of facilities.
Type parameters
Name | Type |
---|---|
T | extends Facility |
TAdded | TAdded |
TRemoved | TRemoved |
Hierarchy
↳
AbstractNearestSubscription
Implements
Constructors
constructor
• new AbstractNearestSubscription<T
, TAdded
, TRemoved
>(facilityLoader
, type
): AbstractNearestSubscription
<T
, TAdded
, TRemoved
>
Creates an instance of a NearestSubscription.
Type parameters
Name | Type |
---|---|
T | extends Facility |
TAdded | TAdded |
TRemoved | TRemoved |
Parameters
Name | Type | Description |
---|---|---|
facilityLoader | FacilityLoader | An instance of the facility loader to search with. |
type | FacilitySearchType | The type of facility to search for. |
Returns
AbstractNearestSubscription
<T
, TAdded
, TRemoved
>
Overrides
AbstractSubscribableArray.constructor
Defined in
src/sdk/navigation/NearestSubscription.ts:75
Properties
facilities
• Protected
Readonly
facilities: T
[] = []
Defined in
src/sdk/navigation/NearestSubscription.ts:58
facilityIndex
• Protected
Readonly
facilityIndex: Map
<TRemoved
, T
>
Defined in
src/sdk/navigation/NearestSubscription.ts:59
facilityLoader
• Protected
Readonly
facilityLoader: FacilityLoader
An instance of the facility loader to search with.
Defined in
src/sdk/navigation/NearestSubscription.ts:75
initialNotifyFunc
• Protected
Readonly
initialNotifyFunc: (sub
: HandlerSubscription
<SubscribableArrayHandler
<T
>>) => void
A function which sends initial notifications to subscriptions.
Type declaration
▸ (sub
): void
A function which sends initial notifications to subscriptions.
Parameters
Name | Type |
---|---|
sub | HandlerSubscription <SubscribableArrayHandler <T >> |
Returns
void
Inherited from
AbstractSubscribableArray.initialNotifyFunc
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:20
notifyDepth
• Protected
notifyDepth: number
= 0
Inherited from
AbstractSubscribableArray.notifyDepth
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:17
onSubDestroyedFunc
• Protected
Readonly
onSubDestroyedFunc: (sub
: HandlerSubscription
<SubscribableArrayHandler
<T
>>) => 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
Name | Type |
---|---|
sub | HandlerSubscription <SubscribableArrayHandler <T >> |
Returns
void
Inherited from
AbstractSubscribableArray.onSubDestroyedFunc
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:23
session
• Protected
session: undefined
| NearestSearchSession
<TAdded
, TRemoved
>
Defined in
src/sdk/navigation/NearestSubscription.ts:61
singletonSub
• Protected
Optional
singletonSub: HandlerSubscription
<SubscribableArrayHandler
<T
>>
Inherited from
AbstractSubscribableArray.singletonSub
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:14
startPromiseResolves
• Protected
Readonly
startPromiseResolves: () => void
[] = []
Defined in
src/sdk/navigation/NearestSubscription.ts:63
subs
• Protected
Optional
subs: HandlerSubscription
<SubscribableArrayHandler
<T
>>[]
Inherited from
AbstractSubscribableArray.subs
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:16
type
• Protected
Readonly
type: FacilitySearchType
The type of facility to search for.
Defined in
src/sdk/navigation/NearestSubscription.ts:75
updatePromiseResolves
• Protected
Readonly
updatePromiseResolves: () => void
[] = []
Defined in
src/sdk/navigation/NearestSubscription.ts:64
Accessors
length
• get
length(): number
The length of this array.
Returns
number
Implementation of
Overrides
AbstractSubscribableArray.length
Defined in
src/sdk/navigation/NearestSubscription.ts:80
started
• get
started(): boolean
Whether or not this subscription has been started.
Returns
boolean
True if started, false otherwise.
Implementation of
Defined in
src/sdk/navigation/NearestSubscription.ts:88
Methods
addFacility
▸ addFacility(facility
, key
): void
Adds a facility to the collection.
Parameters
Name | Type | Description |
---|---|---|
facility | T | The facility to add. |
key | TRemoved | The key to track this facility by. |
Returns
void
Defined in
src/sdk/navigation/NearestSubscription.ts:176
addSubscription
▸ addSubscription(sub
): void
Adds a subscription to this array.
Parameters
Name | Type | Description |
---|---|---|
sub | HandlerSubscription <SubscribableArrayHandler <T >> | 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:98
doUpdate
▸ doUpdate(lat
, lon
, radius
, maxItems
): Promise
<void
>
Executes an update of the nearest search subscription.
Parameters
Name | Type | Description |
---|---|---|
lat | number | The latitude of the current search position. |
lon | number | The longitude of the current search position. |
radius | number | The radius of the search, in meters. |
maxItems | number | The maximum number of items to return in the search. |
Returns
Promise
<void
>
Defined in
src/sdk/navigation/NearestSubscription.ts:149
get
▸ get(index
): T
Gets an item from the array.
Parameters
Name | Type | Description |
---|---|---|
index | number | Thex index of the item to get. |
Returns
T
An item.
Throws
Implementation of
Inherited from
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:77
getArray
▸ getArray(): readonly T
[]
Gets a read-only version of this array.
Returns
readonly T
[]
a read-only version of this array.
Implementation of
Overrides
AbstractSubscribableArray.getArray
Defined in
src/sdk/navigation/NearestSubscription.ts:93
initialNotify
▸ initialNotify(sub
): void
Notifies a subscription of this array's current state.
Parameters
Name | Type | Description |
---|---|---|
sub | HandlerSubscription <SubscribableArrayHandler <T >> | 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
Name | Type | Description |
---|---|---|
index | number | The index that was changed. |
type | SubscribableArrayEventType | The type of subject event. |
modifiedItem? | T | readonly T [] | The item modified by the operation. |
Returns
void
Inherited from
AbstractSubscribableArray.notify
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:100
onResults
▸ onResults(results
): Promise
<void
>
A callback called when results are received.
Parameters
Name | Type | Description |
---|---|---|
results | NearestSearchResults <TAdded , TRemoved > | The results that were received. |
Returns
Promise
<void
>
Defined in
src/sdk/navigation/NearestSubscription.ts:169
onSubDestroyed
▸ onSubDestroyed(sub
): void
Responds to when a subscription to this array is destroyed.
Parameters
Name | Type | Description |
---|---|---|
sub | HandlerSubscription <SubscribableArrayHandler <T >> | The destroyed subscription. |
Returns
void
Inherited from
AbstractSubscribableArray.onSubDestroyed
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:185
removeFacility
▸ removeFacility(key
): void
Removes a facility from the collection.
Parameters
Name | Type | Description |
---|---|---|
key | TRemoved | The key of the facility to remove. |
Returns
void
Defined in
src/sdk/navigation/NearestSubscription.ts:191
start
▸ start(): Promise
<void
>
Starts this search.
Returns
Promise
<void
>
Implementation of
Defined in
src/sdk/navigation/NearestSubscription.ts:107
sub
▸ sub(handler
, initialNotify?
, paused?
): Subscription
Subscribes to changes in this array's state.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
handler | SubscribableArrayHandler <T > | undefined | A function which is called when this array's state changes. |
initialNotify | boolean | false | Whether 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. |
paused | boolean | false | Whether the new subscription should be initialized as paused. Defaults to false . |
Returns
The new subscription.
Implementation of
Inherited from
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:41
tryGet
▸ tryGet(index
): undefined
| T
Tries to get the value from the array.
Parameters
Name | Type | Description |
---|---|---|
index | number | The index of the item to get. |
Returns
undefined
| T
The value or undefined if not found.
Implementation of
Inherited from
AbstractSubscribableArray.tryGet
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:90
unsub
▸ unsub(handler
): void
Unsubscribes a callback function from this array.
Parameters
Name | Type | Description |
---|---|---|
handler | SubscribableArrayHandler <T > | 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
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
Name | Type | Description |
---|---|---|
lat | number | The latitude, in degrees, of the center of the search. |
lon | number | The longitude, in degrees, of the center of the search. |
radius | number | The radius of the search, in meters. |
maxItems | number | The 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
Defined in
src/sdk/navigation/NearestSubscription.ts:130