ArcGISContextManager

Class

The manager exposes context (IArcGISContext), which combines a UserSession with the portal/self and user/self responses to provide a central lookup for platform information, api urls, and other useful properties for developers such as IRequestOptions IUserRequestOptions, IHubRequestOptions etc.

The context is exposed on gthe .context property, and as the authentication changes the .context is re-created. This is done to allow web frameworks to watch for changes on that single property, instead of having to leverage observers or events for change detection.

Please see the ArcGISContext Guide for additional information.

Properties

Property Type Notes
id number

Random identifier useful for debugging issues where race-conditions can result in multiple contexts getting created

Accessors

Accessor Type Notes
context IArcGISContext

Return a reference to the current state. When .setAuthentication() or .clearAuthenentication() are called, the state will be re-created. This is done so frameworks like React or Ember can detect changes.

Methods

Method Returns Notes
Promise<ArcGISContextManager>

Used to create a new instance of the ArcGISContext class.

const ctxMgr = await ArcGISContextManager.create();
Promise<ArcGISContextManager>

Create a new instance of the ArcGISContextManager from a serialized string. This is useful when you want to store the context in a browser's local storage or server side session.

void

Clear the Authentication (UserSession). This should be called when a user signs out of an application, but the application continues running

string

Serialize the context into a string that can be stored and re-hydrated

Promise<void>

Set the Authentication (UserSession) for the context. This should be called when a user signs into a running application.

void

Set the properties hash and re-create the context

Promise<void>

Update the User's Hub Settings Stores in the user-app-resource associated with the hubforarcgis clientId and updates the context

create

Static Static Class Method

Used to create a new instance of the ArcGISContext class.

Parameters

Parameter Type Default Notes
opts Optional IArcGISContextManagerOptions {}

Returns


const ctxMgr = await ArcGISContextManager.create();

deserialize

Static Static Class Method

Create a new instance of the ArcGISContextManager from a serialized string. This is useful when you want to store the context in a browser's local storage or server side session.

Parameters

Parameter Type Default Notes
serializedContext Required string

Returns

clearAuthentication

Class Method

Clear the Authentication (UserSession). This should be called when a user signs out of an application, but the application continues running

  • clearAuthentication() : void

Returns

void

serialize

Class Method

Serialize the context into a string that can be stored and re-hydrated

  • serialize() : string

Returns

string

setAuthentication

Class Method

Set the Authentication (UserSession) for the context. This should be called when a user signs into a running application.

  • setAuthentication(auth: UserSession) : Promise<void>

Parameters

Parameter Type Default Notes
auth Required UserSession

Returns

Promise<void>

setProperties

Class Method

Set the properties hash and re-create the context

  • setProperties(properties: Record<stringany>) : void

Parameters

Parameter Type Default Notes
properties Required Record<stringany>

Returns

void

updateUserHubSettings

Class Method

Update the User's Hub Settings Stores in the user-app-resource associated with the hubforarcgis clientId and updates the context

Parameters

Parameter Type Default Notes
settings Required IUserHubSettings

Returns

Promise<void>

Class defined in common/src/ArcGISContextManager.ts:165