Skip to content

Javascript api

knicos edited this page Jan 17, 2013 · 5 revisions

Basics of the Javascript environment behind the js-eden interface.

  • Accessing Symbols
  • Scripts - Execution and Loading
  • Loading and Configuring Plugins

Accessing Symbols

Observables, functions and procedures are represented as JavaScript objects that are stored in a symbol table. The symbol table can be found at root.symbols. To access a specific symbol you need to give its name: root.symbols["_status"]. It is advisable to limit direct JavaScript interaction with the symbol table to the reading and writing of observable values. More complex interactions are best done via the Eden scripting language.

Getting the value of an observable

root.symbols["_status"].value() returns the current value of the observable. Do not directly use the internal cached_value property as that may not be up-to-date.

Changing the value of an observable

root.symbols["_status"].assign("New Status") changes the value and will trigger any required dependency maintenance. Again, do not directly change cached_value.

Scripts

Using SSI to Load Scripts

Eden.executeFileSSI(path) will ask the server to perform a server-side include of all scripts that might be included by the specified script. A large single script is then returned and processed locally. The benefit of this is that there are fewer requests being made to the server and few separate scripts to process.

Executing a String as a Script

Eden.execute(string) will interpret the string as Eden and execute it.

Loading and Configuring Plugins

eden.loadPlugin(name) will load an already installed plugin which will then make new views available. A list of available plugins can be found in Eden.plugins and a list of already loaded plugins can be found in eden.plugins. Note the upper and lower case "e" is important. Plugins sometimes have configurable options, these can be found in eden.plugins[name].

Clone this wiki locally