-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Pass context to observable 'rs' template #143
Comments
https://observablehq.com/@real-john-cheung/test-rs but my idea is to change those might be global ones into another direction is to replace the not assigned symbols in the input |
I'd rather find the global context -- it must be there if we can refer to variable from one cell to another... |
hmm, after some research and experiments, I think Observable works like this: So there is a 'gobal context' in the runtime, but that's not accessible in the cells (hmm more accurately, the runtime of that page is not accessible in the cells on that page, we can created a new runtime (which run by the page's runtime) like this)... edit |
https://observablehq.com/@real-john-cheung/test-rs |
I don't like the look of this at all... Two questions:
toContext = function(runtime) {
let context = {};
Array.from(runtime._variables) // extract cell-defined symbols
.filter(v => v._name !== null && v._type === 1 && thisModules.get(v._module) === 'self')
.forEach(v => context[v._name] = v._value);
return context;
} |
|
Only import and a cell using |
My progress so far (updates to context not working quite right):
|
@Real-John-Cheung please test if this is working correctly by importing RS from here: https://observablehq.com/@dhowe/rsc |
pls include the link for your test I am aware of issue #1, and I think it is ok like this. I'm confused as to why the |
https://observablehq.com/@real-john-cheung/import-test here is the link |
Let's see if this is possible in 'rs', same way as we pass State.variables to
<<rs>>
in Twine. Simple test: define a js variablefoo
in one cell, refer to it as$foo
inside an 'rs' block in a separate cell.The text was updated successfully, but these errors were encountered: