Skip to content

docs: explain self-referencing callbacks - #960

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

czabaj wants to merge 2 commits into
rescript-lang:masterfrom
czabaj:vg/mutable-self-reference

Conversation

@czabaj

@czabaj czabaj commented Jan 3, 2025 •

Copy link
Copy Markdown

Document how a callback can use a function returned by its registration call through a ref. Use a small subscription example in the v12 mutation guide and explain that the callback must run after registration returns.

Original discussion.

@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 →

Merge current master and move the contribution into the current mutation guide. Replace the React example with a subscription callback and explain its timing requirement.

Co-authored-by: Václav Gröhling <grohling.v@clav.cz>
@fhammerschmidt fhammerschmidt changed the title feat: document ref for self-referencing docs: explain self-referencing callbacks Oct 12, 2026
@fhammerschmidt fhammerschmidt added the ok-to-deploy Trigger deployment if you are sure a PR is safe to deploy. label Oct 12, 2026 — with ChatGPT Codex Connector
@fhammerschmidt
fhammerschmidt enabled auto-merge (squash) October 12, 2026 16:02

This branch was successfully deployed

1 active deployment
fork-preview — 75c16ba7 Deployed Oct 12, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-deploy Trigger deployment if you are sure a PR is safe to deploy.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants