JavaScript callback
===================
Client to server
----------------
To call backend from JavaScript `pantra` defines method: `processCall(oid, func_name, *args)`. Called function
should be allowed by :meth:`~pantra.components.context.Context.allow_call`.
* `oid` - is unique node OID of any node in execution context. There is simple JS API to get OID:
* `OID.get(node)` - get node OID
* `OID.node(oid)` - get node by OID
Otherwise, get node ID with pythonic expression `node.oid`.
* 'func_name` - function defined in local Python script
* `args` - all simple types are serializable including lists and dicts
Example:
.. code-block:: pantra
def init():
ctx.allow_call('call_from_client')
def call_from_client(data):
session.log(data)
Server to client
----------------
To call JavaScript method from Python script use :meth:`~pantra.session.Session.call` method.
All simple types are serializable including lists and dicts.
Example:
.. code-block:: pantra
def go(node):
data = {
'hello': 'from server',
}
session.call("callFromServer", data)