Options
All
  • Public
  • Public/Protected
  • All
Menu

Base class for objects that are typically initialized from a REST endpoint, e.g. a Site, or a MapService.

Provides methods, events and properties common to objects commonly initialized in an asynchronous fashion. This is the sequence of an asynchronous initialization:

  1. The class is instantiated.
  2. The initialize method is called by something looking to initialize the resource.
  3. The subclass asynchronously calls a REST endpoint.
  4. Once the asynchronous call has completed, sets the isInitialized property to true.
  5. If the asynchronous call returned an error, sets the initializationFailure property to the exception and fires the onInitializationFailed event.
  6. The object fires the onInitialized event, regardless of whether there were errors or not.

Hierarchy

Index

Constructors

constructor

  • Initializes a new instance of the {@link geocortex.essentials.AsyncInitializable} class.

    Parameters

    • Optional url: string

      The remote endpoint to initialize against, typically a REST endpoint serving JSON responses.

    Returns AsyncInitializable

Events

onInitializationFailed

onInitializationFailed: function

Occurs when initialization of this object fails.

Type declaration

    • (error: Error): void
    • Parameters

      • error: Error

      Returns void

onInitialized

onInitialized: function

Occurs when initialization succeeds with a response from the REST endpoint. Depending on the API, this response may actually be an error message served as a correct HTTP response.

Type declaration

    • (sender: any): void
    • Parameters

      • sender: any

      Returns void

Properties

Private _initializing

_initializing: boolean

initializationFailure

initializationFailure: Error

The exception that occurred if the object could not be initialized.

isInitialized

isInitialized: boolean

Whether or not the object was successfully initialized.

site

The {@link geocortex.essentials.Site} that this resource belongs to.

url

url: string

The URL that this resource was initialized from.

Methods

Private _configureObject

  • _configureObject(results: any, deepInitialize?: boolean, isFinal?: boolean): void
  • Parameters

    • results: any
    • Optional deepInitialize: boolean
    • Optional isFinal: boolean

    Returns void

Private _initializationFailedHandler

  • _initializationFailedHandler(err: Error): void
  • Parameters

    • err: Error

    Returns void

Private _initializedHandler

  • _initializedHandler(sender: any): void
  • Parameters

    • sender: any

    Returns void

Private _restErrorHandler

  • _restErrorHandler(error: Error): void
  • Parameters

    • error: Error

    Returns void

Private _restLoadHandler

  • _restLoadHandler(deepInitialize: boolean, result: any): void
  • Parameters

    • deepInitialize: boolean
    • result: any

    Returns void

doWhenInitialized

  • doWhenInitialized(callback: function): void
  • doWhenInitialized(scope: any, callback: function): void
  • Parameters

    Returns void

  • Performs a callback function when this instance has been initialized. If this instance is already initialized when this function is called, the callback function will execute immediately.

    Parameters

    • scope: any

      The scope to using when executing the callback - i.e. the value of the 'this' variable in the callback function. This parameter may be ommitted in which cased the first parameter will be used as the callback function.

    • callback: function

      The callback function to execute when this instance has been initialized.

    Returns void

initialize

  • initialize(obj?: any): void
  • Initializes the {@link geocortex.essentials.AsyncInitializable}. This is an asynchronous method, you may subscribe to the onInitialized and onInitializationFailed events for completion information.

    Parameters

    • Optional obj: any

    Returns void