Skip to content

feat: document ref for self-referencing - #960

Open
czabaj wants to merge 1 commit into
rescript-lang:masterfrom
czabaj:vg/mutable-self-reference
Open

feat: document ref for self-referencing#960
czabaj wants to merge 1 commit into
rescript-lang:masterfrom
czabaj:vg/mutable-self-reference

Conversation

@czabaj

@czabaj czabaj commented Jan 3, 2025

Copy link
Copy Markdown

I encountered a problem with valid JS code that was hard to translate into rescript - the problem is discussed here in the forum - it turned out the ref can help with self-referencing.

I promised to add this trick to the documentation, so here it is. Feel free to criticize 😸

I currently added it just to the v11 docs, once this passes validation, I will copy that into other versions as well. I assume it is useful for all versions where mutable let assignment exists?

Here is how it renders

Screenshot 2025-01-03 at 12 38 39

@vercel

vercel Bot commented Jan 3, 2025

Copy link
Copy Markdown

@czabaj is attempting to deploy a commit to the ReScript Association Team on Vercel.

A member of the Team first needs to authorize it.

@czabaj
czabaj marked this pull request as draft January 3, 2025 11:43
@czabaj
czabaj marked this pull request as ready for review January 13, 2025 15:25
@fhammerschmidt

Copy link
Copy Markdown
Member

Sorry I missed this during my christmas break.

The example seems pretty heavy and we usually try to avoid React-specific code in the main documentation. Can you come up with a simpler example that doesn't need React?

@jderochervlk

Copy link
Copy Markdown
Collaborator

@codex can you come up with a different example?

@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

  • Replaced the React-specific dialog example with a smaller, framework-independent listener example that stops itself after receiving its first message. pages/docs/manual/v11.0.0/mutation.mdxL77-L93
  • Updated the accompanying JavaScript output to match the new self-referencing ref example. pages/docs/manual/v11.0.0/mutation.mdxL95-L104
  • Committed the changes as 007a274 (docs: simplify self-referencing ref example) and created PR metadata titled “docs: replace React self-reference example with a listener.”

Testing

  • git diff --check
  • node_modules/@rescript/linux-x64/bin/bsc.exe /tmp/self-reference.res -uncurried -o /tmp/self-reference.js
  • ⚠️ npm test (environment’s installed glob package does not provide the default export expected by the test script under Node.js 24)
  • ⚠️ npm install in compilers/ (the package registry returned HTTP 403 for scheduler-0.23.0.tgz, preventing installation of the pinned ReScript 11 test toolchain)

View task →

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.

3 participants