asg017 / unofficial-observablehq-compiler

An unofficial compiler for Observable notebook syntax
https://www.npmjs.com/package/@alex.garcia/unofficial-observablehq-compiler
115 stars 22 forks source link

Add support for imported views #1

Closed asg017 closed 4 years ago

asg017 commented 5 years ago

I haven't tested this, but I'm pretty sure this won't work:

Notebook 1

viewof a = DOM.input()

md`Typed value: "${a}"`

Notebook 2


import {viewof a} from 'notebook1'

viewof a

md`This notebook's value: ${a}`

Supporting this viewof import would be awesome!

bryangingechen commented 5 years ago

I can tackle this and #2 if you're not already working on this.

asg017 commented 5 years ago

@bryangingechen sure, that would be awesome!

The parser already tells us if the imported cell is a view or not, so this issue should be a simple if statement on that boolean, then importing the viewof x instead of x. Implemenring the mutable keyword may be a little more fun...