Skip to content

Plot cell: allow async, multiple inputs, one output#19

Open
justjake wants to merge 5 commits intoekzhang:mainfrom
justjake:jake--plot-moar
Open

Plot cell: allow async, multiple inputs, one output#19
justjake wants to merge 5 commits intoekzhang:mainfrom
justjake:jake--plot-moar

Conversation

@justjake
Copy link

@justjake justjake commented May 7, 2022

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 Debug button to show Datalog AST #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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant