Interface: ApiStateInterface

api.state

ShapeDiver Viewer - State API

The state interface is part of the global API.

It allows to

  • get an overview of the current state of the viewer instance,
  • influence the state of the viewer instance and its visual representation,
  • add and remove listeners for related events.

Methods

addEventListener(type, callback)

Add a callback to be invoked when a certain event occurs

Parameters:
Name Type Description
type StateEventType

Type of event to subscribe to

callback EventListenerCallback

Function to be called when the event fires

Returns:
Type Description
APIResponse

APIResponse with an EventListenerToken object. The event listener token can be used to remove the event listener by calling removeEventListener.

get()

Retrieve the current state of the viewer

Returns:
Type Description
APIResponse

API response with data of type ViewerAppState. Description of the current state of the viewer application.

removeEventListener(token)

Remove an event listener

Parameters:
Name Type Description
token EventListenerToken

event listener token for event listener to be removed

Returns:
Type Description
APIResponse

APIResponse with a Boolean data, indicating whether the event listener could be removed.

setBusy(busy [, progress])

Register the API as a busy process of the viewer app

Parameters:
Name Type Argument Description
busy Boolean

If true, a busy process will be registered, causing the viewer app to enter busy mode. If false and a busy process of the API had been registered before, it will be removed.

progress Number <optional>

Set the percentage of completion in interval [0,1]. If progress bars are displayed, this will influence them.

Returns:
Type Description
APIResponse

API response with data of type ViewerAppState. Description of the current state of the viewer application.

Members

<readonly> EVENTTYPE

Enum for supported state event types.

Properties:
Name Type Default Description
BUSY busy

The viewer has entered busy state, which means at least one update process is currently going on.

IDLE idle

The viewer has entered idle state, which means there are no more update processes going on.

MESSAGE message

a message which may be displayed to the user

FAILED failed

a message reporting a fatal error, e.g. the WebGL context was lost and could not be recovered

Type Definitions

StateEventType

Status event type, see EVENTTYPE for values

Type:
  • String

ViewerAppState

Viewer state description

Type:
  • Object
Properties:
Name Type Description
busy Boolean

true if the viewer is in busy mode, false if the viewer is in idle mode

progress Number

minimum progress of all processes currently reporting a progress, interval [0,1]

processes Object.<String, Object>

List of currently active processes

failedStatusMessages Array

array of status messages corresponding to fatal errors

ShapeDiver 3D Viewer, Copyright © 2015-2019 ShapeDiver GmbH. Documentation generated by JSDoc 3.5.5 on Wed May 22nd 2019 using the DocStrap template.