The examples in this page use the Prototype library, which is included by default inside a portal. However, the same concepts may be applied using other implementations.
These set of actions can retrieve a list of available Sample projects, and import a specific sample into the workspace.
Samples are contributed to the Studio via extensions, or via the scripting mechanism (Rubles).
This command is executed immediately in a synchronous way.
List the available Samples
To get the JSON list of samples, dispatch this call:
The returned JSON holds this information:
The sample's category
The name of the sample
A unique sample identifier which should also be used when importing a sample
A description of the sample
(currently empty for all samples) Will hold an image URL for the sample
Import a Sample
When importing a sample, the dispatch call should use a sample id that was retrieved via the getSamples action.
Here is a dispatch example:
Listening to Sample Changes
It is possible that some of the samples are loaded or removed after the portal is opened. In this case, the Studio fires events that indicate a Sample addition or removal.
Here is a sample of a way you can listen to such events (based on the studio3-sdk sample):
The update call receives an event object that holds the following information, and can be used to update the UI:
The event identifier (in this case, always 'samples')
'added' or 'deleted'
A JSON representation of the Sample-Info (as described above)