percival icon indicating copy to clipboard operation
percival copied to clipboard

Plot cell: allow async, multiple inputs, one output

Open justjake opened this issue 3 years ago • 0 comments

This PR updates Plot cells to work as more fully-featured JS cells.

  • Plot cells can take multiple input dependencies: (dep1, dep2) => ... or no inputs, () => ....
  • Plot cells can be async, allowing them to access modules with await import(...): async dep => (await import('https://esm.sh/...'))(dep).
  • Plot cells can write a reactive result, using assignment syntax: resultName = () => [{ x: 1 }, { x: 2 }]. Currently this emits one relation, not a set of relations like code cells. A future change could use syntax like { table1, table2 } = () => ... to emit multiple relation outputs.
  • Cell outputs with outerHTML are rendered as HTML (as before). Array outputs are rendered as relations. Otherwise, the output is rendered as JSON. If #16 is merged, I'll replace the simple JSON renderer with the JSON tree inspector used there.

After these changes "plot" vs "code" seem like misnomers - perhaps we should rename these concepts to "datalog" and "js". However, that's a bigger policy/design change.

image

justjake avatar May 07 '22 21:05 justjake