Methods
createError(errorObject) → {Error|null}
From the pieces given over the frame, create and Error type that can then be thrown and or returned.
Parameters:
Name | Type | Description |
---|---|---|
errorObject |
ErrorObject | null |
Returns:
- Type
- Error | null
getReturnValuesAndErrors()
invokeSequence callbacks are listed as (returnValue1, returnValue2, error1, error2) etc
This function returns results like [returnValue1, returnValue2] then [error1, error2].
Helpful for the async adapter.
tryParseJSON()
If the string is valid JSON, it is parsed and returned. If not, then null is returned.
See http://stackoverflow.com/questions/3710204/how-to-check-if-a-string-is-a-valid-json-string-in-javascript-without-using-try
Type Definitions
Command
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
phetioID |
string | the id of the phet-io element | |
method |
string | name of method to invoke | |
args |
Array.<*> |
<optional> |
the parameters needed from the method to invoke |
An object holding the data for a single invocation command. Each Command consists of the needed
values to invoke one method call in the sim frame.
Type:
- Object
LaunchSimOptions
Properties:
Name | Type | Default | Description |
---|---|---|---|
queryString |
string |
""
|
appended to the simulation launch URL, can begin with '?' or '&' or neither |
passThroughQueryParameters |
boolean | Array.<string> |
false
|
Set to true if the query parameters from the wrapper should propagate through to the simulation. Also accepts a string array of the list of accepted query parameters, ignoring all the rest. |
onEvent |
function | null |
null
|
Callback called for each event from the simulation. Note that this listener is called for children events as well as the root. Listener has have two arguments; the first is the event object, and the second is the root event object. The event will either be the root event, or be a child/descendant of the root event. See the PhET-iO dev guide for more information. |
onSimInitialized |
function |
no-op
|
Callback after the sim has been fully initialized and is ready to be displayed. See Client.addSimInitializedListener for more info. |
onPhetioInitialized |
function |
no-op
|
Callback after the PhET-iO layer in the simulation frame is ready for communication. It can receive some PhET-iO commands (such as adding listeners or customization expressions) before the sim starts to launch. See Client.addPhetioInitializedListener for more info. |
onError |
function |
no-op
|
Callback called whenever an error is received from the sim. This listener exists for the lifetime of the wrapper. If wanting to add error listeners that can be removed, see Client.addErrorListener(). |
displaySim |
boolean |
true
|
By default, the sim will be immediately displayed when it starts up. Set
this flag to false in order to stay on the splash screen until after customizations have been applied to the
sim from a wrapper. Display the sim manually by calling
phetioClient.invoke( 'phetioEngine', 'displaySim' ) . |
simStartedMetadata |
Object |
{}
|
This metadata will be logged to the PhET-iO data stream in the
simStarted event on sim launch. |
targetAPIVersion |
string |
CURRENT_VERSION
|
This string tells Client what version the wrapper was written for, regardless of what the current version the wrapper is being used for is. This way Client can automatically migrate from old version APIs to new versions without changing wrapper code. |
forwardZoomKeyboardEventsToSim |
boolean |
false
|
Whether the zoom keyboard events should be forwarded to the sim. Typically important for a full-screen sim iframe. |
The schema for the available options that can be passed to
Client.launchSim()
Type:
- Object