Back to Player SDK

Actions and Selectors

When you initialize the player, the return value is an object with namespaces that each have commands and selectors. For example, the filter selector is in the scene namespace, and can be run as shown:

var api = claraplayer('clara-embed');
var cameras = api.scene.filter({type: 'Camera'});

There is a distinction between Actions, and Selectors.

An Action is a function that makes a change. Every Action will return a promise, so that you may determine when an action has finished, or if it ran into an error. For example, for the fetchAndUse action on the sceneIO module:

player.sceneIO.fetchAndUse(uuid).then(function() {
  console.log('scene: ', uuid, 'has been loaded');
}).catch(function(err) {
  console.log('There was an error fetching: ', uuid);

A Selector will simply return the data you ask for, and is always synchronous.

var cameraId = player.scene.find('My Camera');

Now that you understand Actions and Selectors, learn about tools and events.