This repository was archived by the owner on Apr 27, 2026. It is now read-only.
JavaScript usage documentation improvements #3025
Merged
jonsequitur merged 3 commits intoJun 9, 2023
Merged
Conversation
jonsequitur
force-pushed
the
docs-improvements-2023-06-08
branch
from
June 8, 2023 22:58
aec8316 to
8047288
Compare
| <img width="503" alt="image" src="https://user-images.githubusercontent.com/547415/211661641-057e29fc-8048-4910-983f-14d8380dca8b.png"> | ||
|
|
||
| One notable detail is that the type of the new C# variable has changed from the original declaration. It was originally declared as `int[]`, but after sharing the array back from JavaScript, the C# kernel has a variable called `array` which is of type `JsonDocument`. Because the JavaScript kernel runs in a different process from the .NET subkernels, sharing happens via JSON serialization. Complex types shared from JavaScript to .NET are sent as JSON and deserialized using `System.Text.Json`. There are a few simple types that will be shared as their intuitive .NET counterparts. | ||
| One notable detail here is that the type of the new C# variable has changed from the original declaration. It was originally declared as `int[]`, but after sharing the array back from JavaScript, the C# kernel has a variable called `array` which is of type `JsonDocument`. Because the JavaScript kernel runs in a different process from the .NET subkernels, sharing happens via JSON serialization. Complex types shared from JavaScript to .NET are sent as JSON and deserialized using `System.Text.Json`. There are a few simple types that will be shared as their intuitive .NET counterparts. |
Contributor
There was a problem hiding this comment.
Should we change the screenshot for the above example to use #!set instead of #!share? That may work better since the sharing is by value by default with #!set (and since there will be a nice error if someone tries to share by reference for JavaScript).
|
|
||
| ```javascript | ||
| const doSomething = async () => { | ||
| // Your code here |
Contributor
There was a problem hiding this comment.
Just curious: Does some alternate approach exist that would allow us to execute some arbitrary piece of supplied JavaScript within a top-level scope? I am sure there is good reason to select the above approach - but was just curious if there are alternatives and what downsides these alternatives might have.
shyamnamboodiripad
approved these changes
Jun 9, 2023
shyamnamboodiripad
left a comment
Contributor
There was a problem hiding this comment.
Looks great 👍🏾
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This addresses #2928.