import VersionManagementService from "@arcgis/core/versionManagement/VersionManagementService.js";const VersionManagementService = await $arcgis.import("@arcgis/core/versionManagement/VersionManagementService.js");- Inheritance:
- VersionManagementService→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.28
This class contains metadata about the version management service. The class can be constructed via a url to a version management service. The VersionManagementService grants users to plethora of functionality. The VersionManagementService contains methods for creating a new version, deleting a version, altering a version, changing a version on layers, start/stop reading, start/stop editing, reconciling, posting, and getting version infos. The Version Management Component offers another way to handle versioning using a UI.
Example
// Initialize the VersionManagementService from a urlconst versionManagementService = new VersionManagementService({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/VersionManagementServer"});
// The layers that will be managed under the VersionManagementServiceconst layer1 = new FeatureLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/FeatureServer/12"});const layer2 = new FeatureLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/FeatureServer/13"});const layers = [layer1, layer2];
// The VersionManagementService must be loaded before any methods can be calledawait versionManagementService.load();
// Change the version of two layersversionManagementService.changeVersion( layers, { name: "sde.DEFAULT", guid: "{13DEDC17-5867-4DBC-9855-0736C4C57162}"}, { name: "admin.version", guid: "{422D1B63-D795-4478-A4B1-AD6109377074}"});Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Example
// Create a Version Management Service from a urlconst versionManagementService = new VersionManagementService({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/VersionManagementServer"});Properties
| Property | Type | Class |
|---|---|---|
| | ||
declaredClass readonly inherited | ||
| | ||
loaded readonly | | |
loadError readonly inherited | ||
loadStatus readonly inherited | "not-loaded" | "loading" | "failed" | "loaded" | |
loadWarnings readonly inherited | any[] | |
| | ||
| |
defaultVersionIdentifier
- Type
- VersionIdentifier
Contains the value for the default version's name and GUID.
loaded
- Type
- boolean
Indicates whether the instance has loaded. When true, the properties of the object can be accessed.
- Default value
- false
loadError
The Error object returned if an error occurred while loading.
loadStatus
- Type
- "not-loaded" | "loading" | "failed" | "loaded"
Represents the status of a load() operation.
| Value | Description |
|---|---|
| not-loaded | The object's resources have not loaded. |
| loading | The object's resources are currently loading. |
| loaded | The object's resources have loaded without errors. |
| failed | The object's resources failed to load. See loadError for more details. |
- Default value
- "not-loaded"
loadWarnings
- Type
- any[]
A list of warnings which occurred while loading.
url
- Type
- string
The absolute URL of the REST endpoint for the version management service. The URL may either point to a resource on ArcGIS Enterprise or ArcGIS Online.
Methods
| Method | Signature | Class |
|---|---|---|
fromJSON inherited static | fromJSON(json: any): any | |
alterVersion(versionIdentifier: VersionIdentifier, props: AlterVersionParametersProperties): Promise<boolean> | | |
cancelLoad inherited | cancelLoad(): this | |
canRedo(versionIdentifier: VersionIdentifier): boolean | | |
canUndo(versionIdentifier: VersionIdentifier): boolean | | |
changeVersion(input: WebMap | ReadonlyCollection<Layer> | Layer[] | Network, fromVersion: Date | VersionIdentifier, toVersion: Date | VersionIdentifier): Promise<boolean> | | |
changeVersionWithResult(input: WebMap | Collection<VersionAdapter> | VersionAdapter[], fromVersion: Date | VersionIdentifier, toVersion: Date | VersionIdentifier): Promise<Map<VersionAdapter, ServiceResult>> | | |
createVersion(props: CreateVersionParametersProperties): Promise<VersionInfoExtendedJSON> | | |
deleteVersion(versionIdentifier: VersionIdentifier): Promise<boolean> | | |
getLockType(versionIdentifier: VersionIdentifier): LockType | | |
getVersionIdentifierFromGuid(guid: string): Promise<VersionIdentifier | null | undefined> | | |
getVersionIdentifierFromName(name: string): Promise<VersionIdentifier | null | undefined> | | |
getVersionInfoExtended(versionIdentifier: VersionIdentifier): Promise<VersionInfoExtendedJSON | null | undefined> | | |
getVersionInfos(props?: GetVersionInfosParametersProperties): Promise<VersionInfoJSON[]> | | |
isFulfilled inherited | isFulfilled(): boolean | |
isRejected inherited | isRejected(): boolean | |
isResolved inherited | isResolved(): boolean | |
load(options?: AbortOptions | null | undefined): Promise<this> | | |
post(versionIdentifier: VersionIdentifier): Promise<PostResult> | | |
reconcile(versionIdentifier: VersionIdentifier, props?: ReconcileParametersProperties): Promise<ReconcileResult> | | |
redo(versionIdentifier: VersionIdentifier): void | | |
startEditing(versionIdentifier: VersionIdentifier): Promise<boolean> | | |
startEditingWithResult(versionIdentifier: VersionIdentifier): Promise<ServiceResult> | | |
startReading(versionIdentifier: VersionIdentifier): Promise<boolean> | | |
startReadingWithResult(versionIdentifier: VersionIdentifier): Promise<ServiceResult> | | |
stopEditing(versionIdentifier: VersionIdentifier, saveEdits: boolean): Promise<boolean> | | |
stopEditingWithResult(versionIdentifier: VersionIdentifier, saveEdits: boolean): Promise<ServiceResult> | | |
stopReading(versionIdentifier: VersionIdentifier): Promise<boolean> | | |
stopReadingWithResult(versionIdentifier: VersionIdentifier): Promise<ServiceResult> | | |
toJSON inherited | toJSON(): any | |
undo(versionIdentifier: VersionIdentifier): void | | |
when inherited | when<TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2> |
fromJSON
- Signature
-
fromJSON (json: any): any
Creates a new instance of this class and initializes it with values from a JSON object
generated from an ArcGIS product. The object passed into the input json
parameter often comes from a response to a query operation in the REST API or a
toJSON()
method from another ArcGIS product. See the Using fromJSON()
topic in the Guide for details and examples of when and how to use this function.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| json | A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects. | |
- Returns
- any
Returns a new instance of this class.
alterVersion
- Signature
-
alterVersion (versionIdentifier: VersionIdentifier, props: AlterVersionParametersProperties): Promise<boolean>
The alter operation allows you to change the geodatabase version's name, description, owner, and access permissions.
License
This method requires the feature service and version management service to be published with ArcGIS Enterprise version 11.2 or higher. Organization members must be assigned a license for the ArcGIS Advanced Editing user type extension to use this method.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | | |
| props | Contains properties that will be altered. | |
Example
// Make sure the VersionManagementService is loadedawait versionManagementService.load();
const result = await versionManagementService.alterVersion( { name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" }, { versionName: "versionName", ownerName: "newOwner", description: "newDescription", access: "public" }); cancelLoad
- Signature
-
cancelLoad (): this
Cancels a load() operation if it is already in progress.
- Returns
- this
canUndo
- Signature
-
canUndo (versionIdentifier: VersionIdentifier): boolean
canUndo may be used to verify that an undo() operation is possible.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | |
- Returns
- boolean
Indicates whether an undo operation is possible.
changeVersion
- Signature
-
changeVersion (input: WebMap | ReadonlyCollection<Layer> | Layer[] | Network, fromVersion: Date | VersionIdentifier, toVersion: Date | VersionIdentifier): Promise<boolean>
Method used to change a layer's version/moment or network's version/moment. Method allows changing version from named version to named version, or from default version to a moment and vice versa.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| input | WebMap | ReadonlyCollection<Layer> | Layer[] | Network | Input used to change version on layers or network. | |
| fromVersion | Current Version or Date moment. | | |
| toVersion | Incoming Version or Date. | |
Example
// Initialize the VersionManagementService from a urlconst versionManagementService = new VersionManagementService({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/VersionManagementServer"});
const layer1 = new FeatureLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/12"});const layer2 = new FeatureLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/13"});const layers = [layer1, layer2];
// Make sure the VersionManagementService is loadedawait versionManagementService.load();
await versionManagementService.changeVersion( layers, { name: "sde.DEFAULT", guid: "{13DEDC17-5867-4DBC-9855-0736C4C57162}"}, { name: "admin.version", guid: "{422D1B63-D795-4478-A4B1-AD6109377074}"}); changeVersionWithResult
- Signature
-
changeVersionWithResult (input: WebMap | Collection<VersionAdapter> | VersionAdapter[], fromVersion: Date | VersionIdentifier, toVersion: Date | VersionIdentifier): Promise<Map<VersionAdapter, ServiceResult>>
- Since
- ArcGIS Maps SDK for JavaScript 4.30
Method used to change a layer's version/moment or network's version/moment. Method allows changing version from named version to named version, or from default version to a moment and vice versa.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| input | Input used to change version on layers. | | |
| fromVersion | Current Version or Date moment. | | |
| toVersion | Incoming Version or Date. | |
- Returns
- Promise<Map<VersionAdapter, ServiceResult>>
When resolved, returns a map of version adapter to result.
Example
const [utils, VersionManagementService, FeatureLayer] = await $arcgis.import([ "@arcgis/core/versionManagement/versionAdapters/utils.js", "@arcgis/core/versionManagement/VersionManagementService.js", "@arcgis/core/layers/FeatureLayer.js"]);// Initialize the VersionManagementService from a urlconst versionManagementService = new VersionManagementService({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/VersionManagementServer"});
const layer1 = new FeatureLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/12"});const layer2 = new FeatureLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/13"});const adapters = utils.createVersionAdapters([layer1, layer2]);
// Make sure the VersionManagementService is loadedawait versionManagementService.load();
await versionManagementService.changeVersionWithResult( adapters, { name: "sde.DEFAULT", guid: "{13DEDC17-5867-4DBC-9855-0736C4C57162}"}, { name: "admin.version", guid: "{422D1B63-D795-4478-A4B1-AD6109377074}"}); createVersion
- Signature
-
createVersion (props: CreateVersionParametersProperties): Promise<VersionInfoExtendedJSON>
Creates a new version given the following parameters.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| props | Contains properties required to create a version. | |
- Returns
- Promise<VersionInfoExtendedJSON>
Contains information about newly created version.
Example
// Make sure the VersionManagementService is loadedawait versionManagementService.load();
// Create a version by passing the new version name, description, and access type set to 'public'.const version = await versionManagementService.createVersion({ versionName: "versionName", description: "description", access: "public"}); deleteVersion
- Signature
-
deleteVersion (versionIdentifier: VersionIdentifier): Promise<boolean>
Deletes a version given the following parameters.
License
This method requires the feature service and version management service to be published with ArcGIS Enterprise version 11.2 or higher. Organization members must be assigned a license for the ArcGIS Advanced Editing user type extension to use this method.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | |
Example
// Make sure the VersionManagementService is loadedawait versionManagementService.load();
versionManagementService.deleteVersion({ name: "versionName", guid: "{422D1B63-D795-4478-A4B1-AD6109377075}"}); getLockType
- Signature
-
getLockType (versionIdentifier: VersionIdentifier): LockType
Returns the current client lock type on a given version.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | |
- Returns
- LockType
Specifies the lock type on the version. Returns either
"edit","none", or"read".
Example
versionManagementService.getLockType({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" }); getVersionIdentifierFromGuid
- Signature
-
getVersionIdentifierFromGuid (guid: string): Promise<VersionIdentifier | null | undefined>
This method will return the VersionIdentifier given the guid of the version.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| guid | GUID of version. | |
- Returns
- Promise<VersionIdentifier | null | undefined>
Returns VersionIdentifier.
getVersionIdentifierFromName
- Signature
-
getVersionIdentifierFromName (name: string): Promise<VersionIdentifier | null | undefined>
This method will return the VersionIdentifier given the name of the version.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| name | Name of version. | |
- Returns
- Promise<VersionIdentifier | null | undefined>
Returns VersionIdentifier.
getVersionInfoExtended
- Signature
-
getVersionInfoExtended (versionIdentifier: VersionIdentifier): Promise<VersionInfoExtendedJSON | null | undefined>
Method used to get extended information about a version.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | |
- Returns
- Promise<VersionInfoExtendedJSON | null | undefined>
Contains extended info about given version.
Example
// Make sure the VersionManagementService is loadedawait versionManagementService.load();
const version = await versionManagementService.getVersionInfoExtended({ guid: "{422D1B63-D795-4478-A4B1-AD6109377075}", name: "versionName"}); getVersionInfos
- Signature
-
getVersionInfos (props?: GetVersionInfosParametersProperties): Promise<VersionInfoJSON[]>
Returns information about a version or versions. If no arguments are provided, this method will return all versions accessible to the currently logged-in user.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| props | | |
- Returns
- Promise<VersionInfoJSON[]>
Contains info of versions.
Example
// Make sure the VersionManagementService is loadedawait versionManagementService.load();
const versions = await versionManagementService.getVersionInfos({ ownerFilter: "publisher1", includeHidden: true }); isFulfilled
- Signature
-
isFulfilled (): boolean
isFulfilled() may be used to verify if creating an instance of the class is fulfilled (either resolved or rejected).
If it is fulfilled, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been fulfilled (either resolved or rejected).
isRejected
- Signature
-
isRejected (): boolean
isRejected() may be used to verify if creating an instance of the class is rejected.
If it is rejected, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been rejected.
isResolved
- Signature
-
isResolved (): boolean
isResolved() may be used to verify if creating an instance of the class is resolved.
If it is resolved, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been resolved.
post
- Signature
-
post (versionIdentifier: VersionIdentifier): Promise<PostResult>
The Post operation allows the client to post the changes in their version to the default version. A reconcile operation must be performed prior to post.
License
This method requires the feature service and version management service to be published with ArcGIS Enterprise version 11.2 or higher. Organization members must be assigned a license for the ArcGIS Advanced Editing user type extension to use this method.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | |
- Returns
- Promise<PostResult>
Returns the result of the post.
Example
// Make sure the VersionManagementService is loadedawait versionManagementService.load();
const postResult = await versionManagementService.post({ guid: "{422D1B63-D795-4478-A4B1-AD6109377075}", name: "versionName"}); reconcile
- Signature
-
reconcile (versionIdentifier: VersionIdentifier, props?: ReconcileParametersProperties): Promise<ReconcileResult>
Use the reconcile operation to reconcile a branch version with the default version. The reconcile operation requires that you are the only user currently editing the version and remain so throughout the reconcile process until you save or post your edits. You must have full permissions to all the feature classes that have been modified in the version being edited. This operation detects differences between the branch version and the default version and flags these differences as conflicts.
License
This method requires the feature service and version management service to be published with ArcGIS Enterprise version 11.2 or higher. Organization members must be assigned a license for the ArcGIS Advanced Editing user type extension to use this method.
Changes to Reconcile
Starting with ArcGIS Server 12.0, calling reconcile will now save pending edits to the version as part of the operation. In addition, calling stopEditing will block post until another reconcile is performed.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | | |
| props | Properties used for a reconcile. | |
- Returns
- Promise<ReconcileResult>
Returns the result of the reconcile.
Example
// Make sure the VersionManagementService is loadedawait versionManagementService.load();
const reconcileResult = await versionManagementService.reconcile({ guid: "{422D1B63-D795-4478-A4B1-AD6109377075}", name: "versionName"},{ abortIfConflicts: true, conflictDetection: "by-object", withPost: false}); redo
- Signature
-
redo (versionIdentifier: VersionIdentifier): void
This method redos the last edit made while in an edit session.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | |
- Returns
- void
startEditing
- Signature
-
startEditing (versionIdentifier: VersionIdentifier): Promise<boolean>
Using the specified session ID an exclusive lock is obtained for the session on the version. The exclusive lock can only be obtained if no other shared or exclusive locks are present and the session currently holds a shared lock. The exclusive lock ensures read and write isolation for the session holding the lock. The exclusive lock is downgraded to a shared lock by using the stopEditing operation.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | |
Example
// Make sure the VersionManagementService is loadedawait versionManagementService.load();
versionManagementService.startEditing({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" }); startEditingWithResult
- Signature
-
startEditingWithResult (versionIdentifier: VersionIdentifier): Promise<ServiceResult>
- Since
- ArcGIS Maps SDK for JavaScript 4.30
Using the specified session ID an exclusive lock is obtained for the session on the version. The exclusive lock can only be obtained if no other shared or exclusive locks are present and the session currently holds a shared lock. The exclusive lock ensures read and write isolation for the session holding the lock. The exclusive lock is downgraded to a shared lock by using the stopEditing operation.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | |
- Returns
- Promise<ServiceResult>
Specifies if start editing was successful.
Example
// Make sure the VersionManagementService is loadedawait versionManagementService.load();
versionManagementService.startEditingWithResult({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" }); startReading
- Signature
-
startReading (versionIdentifier: VersionIdentifier): Promise<boolean>
Using the specified client generated session ID, a shared lock is obtained for the session if the version is not already being edited by another user/session.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | |
Example
// Make sure the VersionManagementService is loadedawait versionManagementService.load();
versionManagementService.startReading({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" }); startReadingWithResult
- Signature
-
startReadingWithResult (versionIdentifier: VersionIdentifier): Promise<ServiceResult>
- Since
- ArcGIS Maps SDK for JavaScript 4.30
Using the specified client generated session ID, a shared lock is obtained for the session if the version is not already being edited by another user/session.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | |
- Returns
- Promise<ServiceResult>
Specifies if start reading was successful.
Example
// Make sure the VersionManagementService is loadedawait versionManagementService.load();
versionManagementService.startReadingWithResult({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" }); stopEditing
- Signature
-
stopEditing (versionIdentifier: VersionIdentifier, saveEdits: boolean): Promise<boolean>
Using the specified session id, the exclusive lock for the version is downgraded to a shared lock. The saveEdits parameter specifies if the edits for the session should be saved (true) or discarded (false).
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | | |
| saveEdits | If set to true edits will be saved, if false edits will not be saved. | |
Example
// Make sure the VersionManagementService is loadedawait versionManagementService.load();
versionManagementService.stopEditing( { name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" }, true,); stopEditingWithResult
- Signature
-
stopEditingWithResult (versionIdentifier: VersionIdentifier, saveEdits: boolean): Promise<ServiceResult>
- Since
- ArcGIS Maps SDK for JavaScript 4.30
Using the specified session id, the exclusive lock for the version is downgraded to a shared lock. The saveEdits parameter specifies if the edits for the session should be saved (true) or discarded (false).
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | | |
| saveEdits | If set to true edits will be saved, if false edits will not be saved. | |
- Returns
- Promise<ServiceResult>
Specifies if stop editing was successful.
Example
// Make sure the VersionManagementService is loadedawait versionManagementService.load();
versionManagementService.stopEditingWithResult( { name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" }, true,); stopReading
- Signature
-
stopReading (versionIdentifier: VersionIdentifier): Promise<boolean>
The shared lock is released on the version.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | |
Example
// Make sure the VersionManagementService is loadedawait versionManagementService.load();
versionManagementService.stopReading({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" }); stopReadingWithResult
- Signature
-
stopReadingWithResult (versionIdentifier: VersionIdentifier): Promise<ServiceResult>
- Since
- ArcGIS Maps SDK for JavaScript 4.30
The shared lock is released on the version.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | |
- Returns
- Promise<ServiceResult>
Specifies if stop reading was successful.
Example
// Make sure the VersionManagementService is loadedawait versionManagementService.load();
versionManagementService.stopReadingWithResult({ name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" }); toJSON
- Signature
-
toJSON (): any
Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.
- Returns
- any
The ArcGIS portal JSON representation of an instance of this class.
undo
- Signature
-
undo (versionIdentifier: VersionIdentifier): void
This method undos the last edit made while in an edit session.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | |
- Returns
- void
when
- Signature
-
when <TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2>
when() may be leveraged once an instance of the class is created. This method takes two input parameters: an onFulfilled function and an onRejected function.
The onFulfilled executes when the instance of the class loads. The
onRejected executes if the instance of the class fails to load.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| onFulfilled | OnFulfilledCallback<this, TResult1> | null | undefined | The function to call when the promise resolves. | |
| onRejected | The function to execute when the promise fails. | |
- Returns
- Promise<TResult1 | TResult2>
Returns a new promise for the result of
onFulfilledthat may be used to chain additional functions.
Example
// Although this example uses MapView, any class instance that is a promise may use when() in the same waylet view = new MapView();view.when(function(){ // This function will execute once the promise is resolved}, function(error){ // This function will execute if the promise is rejected due to an error});