Skip to content

BasemapStyleSession

Class

BasemapStyleSession is a class that extends BaseSession to manage sessions for basemap styles. It provides methods to BasemapStyleSession.start a new session which should be used instead of constructing a new instance directly.

Inheritance: BasemapStyleSessionBaseSession

Constructors

constructor

Class Constructor
new BasemapStyleSession(paramsIBasemapSessionParams): BasemapStyleSession

Creates an instance of BasemapStyleSession. Constructing BasemapStyleSession directly is discouraged. Instead, use the static method BasemapStyleSession.start to start a new session.

Parameters
ParameterType
paramsIBasemapSessionParams
Returns 
BasemapStyleSession

Events

Properties

Hide inherited properties
PropertyTypeNotes
string | IAuthenticationManager

The authentication manager or token used for the session. This can be an instance of ApiKeyManager, ArcGISIdentityManager, ApplicationCredentialsManager or a string token.

duration
inherited
number

The duration of the session in seconds. This is used to determine how long the session will last when the session is refreshed.

endTime
inherited
Date

The end time of the session. This is the time returned from the API when the session will end.

expires
inherited
Date

The expiration date of the session. This is the BaseSession.endTime minus the BaseSession.safetyMargin. This is used internally to determine if the session is expired.

portal
inherited
string

The portal URL that the session is associated with. This generally is not used but exists to implement the IAuthenticationManager interface.

safetyMargin
inherited
number

The safety margin in milliseconds. This subtracted from the BaseSession.endTime to get the BaseSession.expiration.

string

The URL used to start the session.

startTime
inherited
Date

The start time of the session. This is the time returned from the API when the session war started.

styleFamily
inherited
StyleFamily

The style family of the session. This is used to determine the type of basemap styles that are available.

token
inherited
string

The token for the session.

error
inherited
(eError) => void

Event handler for when an error occurs during session management.

authentication

inherited
Class Property
authentication: string | IAuthenticationManager

The authentication manager or token used for the session. This can be an instance of ApiKeyManager, ArcGISIdentityManager, ApplicationCredentialsManager or a string token.

duration

inherited
Class Property
duration: number

The duration of the session in seconds. This is used to determine how long the session will last when the session is refreshed.

Inherited from BaseSession.duration

endTime

inherited
Class Property
endTime: Date

The end time of the session. This is the time returned from the API when the session will end.

Inherited from BaseSession.endTime

expires

inherited
Class Property
expires: Date

The expiration date of the session. This is the BaseSession.endTime minus the BaseSession.safetyMargin. This is used internally to determine if the session is expired.

Inherited from BaseSession.expires

portal

inherited
Class Property
portal: string

The portal URL that the session is associated with. This generally is not used but exists to implement the IAuthenticationManager interface.

Inherited from BaseSession.portal

safetyMargin

inherited
Class Property
safetyMargin: number

The safety margin in milliseconds. This subtracted from the BaseSession.endTime to get the BaseSession.expiration.

startSessionUrl

inherited
Class Property
startSessionUrl: string

The URL used to start the session.

startTime

inherited
Class Property
startTime: Date

The start time of the session. This is the time returned from the API when the session war started.

Inherited from BaseSession.startTime

styleFamily

inherited
Class Property
styleFamily: StyleFamily

The style family of the session. This is used to determine the type of basemap styles that are available.

token

inherited
Class Property
token: string

The token for the session.

Inherited from BaseSession.token

error

staticinherited
Class Property
error: (eError) => void = ...

Event handler for when an error occurs during session management.

Type declaration
    function(eError): void

    Event handler for when an error occurs during session management.

    Parameters
    ParameterType
    eError
    Returns 
    void
Inherited from BaseSession.error

Accessors

Hide inherited accessors
AccessorReturnsNotes
get autoRefresh()
inherited
boolean

Indicates if the session is set to automatically refresh when it expires.

get canRefresh()
inherited
boolean

Indicates if the session can be refreshed. This is always true for this basemap sessions.

get checkingExpirationTime()
inherited
boolean

Indicates if the session is currently checking for expiration time.

get isExpired()
inherited
boolean

Checks if the session is expired.

number

Returns the number of milliseconds until the session token is no longer valid. If the session is expired, it will return 0.

get secondsUntilExpiration()
inherited
number

Returns the number of seconds until the session is no longer valid rounded down. If the session is expired, it will return 0.

autoRefresh

inherited
Class Accessor
get autoRefresh(): boolean

Indicates if the session is set to automatically refresh when it expires.

Returns 
boolean
  • Returns true if auto-refresh is enabled, otherwise false.

canRefresh

inherited
Class Accessor
get canRefresh(): boolean

Indicates if the session can be refreshed. This is always true for this basemap sessions.

Returns 
boolean
  • Always returns true.

checkingExpirationTime

inherited
Class Accessor
get checkingExpirationTime(): boolean

Indicates if the session is currently checking for expiration time.

Returns 
boolean
  • Returns true if the session is checking for expiration time, otherwise false.

isExpired

inherited
Class Accessor
get isExpired(): boolean

Checks if the session is expired.

Returns 
boolean

millisecondsUntilExpiration

inherited
Class Accessor
get millisecondsUntilExpiration(): number

Returns the number of milliseconds until the session token is no longer valid. If the session is expired, it will return 0.

Returns 
number

secondsUntilExpiration

inherited
Class Accessor
get secondsUntilExpiration(): number

Returns the number of seconds until the session is no longer valid rounded down. If the session is expired, it will return 0.

Returns 
number

Methods

Hide inherited methods
MethodReturnsNotes
destroy()
inherited
void

Removes all event listeners and disables auto-refresh and expiration time checking. This is useful for cleaning up the session when it is no longer needed or replaced with a new session.

void

Disables auto-refresh for the session. This will stop automatically refreshing the session when it expires. This will not stop checking the expiration time of the session. If you want to stop automated expiration checking, call BaseSession.disableCheckingExpirationTime after calling this method.

void

Stops checking the expiration time of the session. This will clear the interval that was set by BaseSession.startCheckingExpirationTime.

void

Enables auto-refresh for the session. This will automatically refresh the session when it expires. It will also start checking the expiration time of the session if it is not already started via BaseSession.enableCheckingExpirationTime.

any

Starts checking the expiration time of the session. This will check the expiration time immediately and then on an interval. If the session is expired, it will emit an "expired" event.

getToken()
inherited
Promise<string>

Gets the session token. If the session is expired, it will refresh the credentials and return the new token.

isSessionExpired()
inherited
boolean

Checks if the session is expired. If it is expired, it emits an "expired" event and disables expiration time checking. The event will fire before the method returns true.

off(event, handler)
inherited
void

A handler that will remove a listener from a given event.

on(event, handler)
inherited
void

A handler that listens for an eventName and returns custom handler.

once(event, handler)
inherited
void

A handler that listens for an event once and returns a custom handler. Events listened to with this method cannot be removed with BasemapSession.off.

Promise<BasemapStyleSession>

Refreshes the session credentials by starting a new session. This will emit a "refreshed" event with the previous and current session details.

start(params)Promise<BasemapStyleSession>

Starts a new basemap style session.

startSession(__namedParameters, SessionClass)
inherited
Promise<T>

Starts a new session using the provided parameters and returns an instance of the session class.

destroy

inherited
Class Method
destroy(): void

Removes all event listeners and disables auto-refresh and expiration time checking. This is useful for cleaning up the session when it is no longer needed or replaced with a new session.

Returns 
void
Inherited from BaseSession.destroy

disableAutoRefresh

inherited
Class Method
disableAutoRefresh(): void

Disables auto-refresh for the session. This will stop automatically refreshing the session when it expires. This will not stop checking the expiration time of the session. If you want to stop automated expiration checking, call BaseSession.disableCheckingExpirationTime after calling this method.

Returns 
void

disableCheckingExpirationTime

inherited
Class Method
disableCheckingExpirationTime(): void

Stops checking the expiration time of the session. This will clear the interval that was set by BaseSession.startCheckingExpirationTime.

Returns 
void

enableAutoRefresh

inherited
Class Method
enableAutoRefresh(): void

Enables auto-refresh for the session. This will automatically refresh the session when it expires. It will also start checking the expiration time of the session if it is not already started via BaseSession.enableCheckingExpirationTime.

Returns 
void

enableCheckingExpirationTime

inherited
Class Method
enableCheckingExpirationTime(): any

Starts checking the expiration time of the session. This will check the expiration time immediately and then on an interval. If the session is expired, it will emit an "expired" event.

Returns 
any

getToken

inherited
Class Method
getToken(): Promise<string>

Gets the session token. If the session is expired, it will refresh the credentials and return the new token.

Returns 
Promise<string>

A promise that resolves to the session token.

Inherited from BaseSession.getToken

isSessionExpired

inherited
Class Method
isSessionExpired(): boolean

Checks if the session is expired. If it is expired, it emits an "expired" event and disables expiration time checking. The event will fire before the method returns true.

Returns 
boolean
  • Returns true if the session is expired, otherwise false.

off

inherited
Class Method
off(event"refreshed", handler(e{ current: { endTime: Date; expires: Date; startTime: Date; token: string }; previous: { endTime: Date; expires: Date; startTime: Date; token: string } }) => void): void

A handler that will remove a listener from a given event.

Parameters
ParameterTypeNotes
event"refreshed"
handler(e{ current: { endTime: Date; expires: Date; startTime: Date; token: string }; previous: { endTime: Date; expires: Date; startTime: Date; token: string } }) => void

A function of what to do when eventName was called.

Returns 
void
Inherited from BaseSession.off
off(event"expired", handler(e{ endTime: Date; expires: Date; startTime: Date; token: string }) => void): void
Parameters
ParameterType
event"expired"
handler(e{ endTime: Date; expires: Date; startTime: Date; token: string }) => void
Returns 
void
Inherited from BaseSession.off
off(event"error", handler(eError) => void): void
Parameters
ParameterType
event"error"
handler(eError) => void
Returns 
void
Inherited from BaseSession.off

on

inherited
Class Method
on(event"refreshed", handler(e{ current: { endTime: Date; expires: Date; startTime: Date; token: string }; previous: { endTime: Date; expires: Date; startTime: Date; token: string } }) => void): void

A handler that listens for an eventName and returns custom handler.

Parameters
ParameterTypeNotes
event"refreshed"
handler(e{ current: { endTime: Date; expires: Date; startTime: Date; token: string }; previous: { endTime: Date; expires: Date; startTime: Date; token: string } }) => void

A function of what to do when eventName was called.

Returns 
void
Inherited from BaseSession.on
on(event"expired", handler(e{ endTime: Date; expires: Date; startTime: Date; token: string }) => void): void
Parameters
ParameterType
event"expired"
handler(e{ endTime: Date; expires: Date; startTime: Date; token: string }) => void
Returns 
void
Inherited from BaseSession.on
on(event"error", handler(eError) => void): void
Parameters
ParameterType
event"error"
handler(eError) => void
Returns 
void
Inherited from BaseSession.on

once

inherited
Class Method
once(event"refreshed", handler(e{ current: { endTime: Date; expires: Date; startTime: Date; token: string }; previous: { endTime: Date; expires: Date; startTime: Date; token: string } }) => void): void

A handler that listens for an event once and returns a custom handler. Events listened to with this method cannot be removed with BasemapSession.off.

Parameters
ParameterTypeNotes
event"refreshed"
handler(e{ current: { endTime: Date; expires: Date; startTime: Date; token: string }; previous: { endTime: Date; expires: Date; startTime: Date; token: string } }) => void

A function of what to do when eventName was called.

Returns 
void
Inherited from BaseSession.once
once(event"expired", handler(e{ endTime: Date; expires: Date; startTime: Date; token: string }) => void): void
Parameters
ParameterType
event"expired"
handler(e{ endTime: Date; expires: Date; startTime: Date; token: string }) => void
Returns 
void
Inherited from BaseSession.once
once(event"error", handler(eError) => void): void
Parameters
ParameterType
event"error"
handler(eError) => void
Returns 
void
Inherited from BaseSession.once

refreshCredentials

inherited
Class Method
refreshCredentials(): Promise<BasemapStyleSession>

Refreshes the session credentials by starting a new session. This will emit a "refreshed" event with the previous and current session details.

Returns 
Promise<BasemapStyleSession>

A promise that resolves to the current instance of the session.

start

static
Class Method
start(paramsIStartSessionParams): Promise<BasemapStyleSession>

Starts a new basemap style session.

Parameters
ParameterType
paramsIStartSessionParams
Returns 
Promise<BasemapStyleSession>

startSession

staticinherited
Class Method
startSession(__namedParameters{ authentication: string | IAuthenticationManager; autoRefresh?: boolean; duration?: number; safetyMargin?: number; startSessionUrl?: string; styleFamily?: StyleFamily }, SessionClass(paramsIBasemapSessionParams) => T): Promise<T>

Starts a new session using the provided parameters and returns an instance of the session class.

Parameters
ParameterTypeNotes
__namedParameters{ authentication: string | IAuthenticationManager; autoRefresh?: boolean; duration?: number; safetyMargin?: number; startSessionUrl?: string; styleFamily?: StyleFamily }
SessionClass(paramsIBasemapSessionParams) => T

The class to use for the session.

Returns 
Promise<T>

A promise that resolves to an instance of the session class.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.