Skip to content

Clarify change: callback signature as () => void in AFM spec - #938

Merged
manzt merged 1 commit into
mainfrom
push-vuptoqxzwoxx
Mar 6, 2026
Merged

Clarify change: callback signature as () => void in AFM spec#938
manzt merged 1 commit into
mainfrom
push-vuptoqxzwoxx

Conversation

@manzt

@manzt manzt commented Mar 4, 2026

Copy link
Copy Markdown
Owner

Closes #931

See marimo-team/marimo#7989.

The AFM docs and types previously used Function / ChangeEventHandler<Payload> for the on("change:...") callback, which implied (or in the types case, required) arguments like the model instance and new value. These extra arguments are a Backbone.js implementation detail leaked from ipywidgets' internals — they are not part of the AFM contract and are not provided by other host platforms like marimo.

This updates the spec, types, and type tests to make the () => void signature explicit. Widget authors should use model.get() inside the callback to read the current value. The docs now include an example and a note explaining the portability concern.

@changeset-bot

changeset-bot Bot commented Mar 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5224a76

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@anywidget/types Minor
anywidget Patch
@anywidget/react Patch
@anywidget/svelte Patch
@anywidget/vue Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@manzt
manzt force-pushed the push-vuptoqxzwoxx branch from c5922fa to 7669746 Compare March 4, 2026 17:57
Closes #931

See marimo-team/marimo#7989.

The AFM docs and types previously used `Function` /
`ChangeEventHandler<Payload>` for the `on("change:...")` callback, which
implied (or in the types case, required) arguments like the model
instance and new value. These extra arguments are a Backbone.js
implementation detail leaked from ipywidgets' internals — they are not
part of the AFM contract and are not provided by other host platforms
like marimo.

This updates the spec, types, and type tests to make the `() => void`
signature explicit. Widget authors should use `model.get()` inside the
callback to read the current value. The docs now include an example and
a note explaining the portability concern.
@manzt
manzt force-pushed the push-vuptoqxzwoxx branch from 7669746 to 5224a76 Compare March 4, 2026 17:58
@rgbkrk

rgbkrk commented Mar 4, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

@manzt
manzt merged commit 88298fd into main Mar 6, 2026
11 checks passed
@manzt
manzt deleted the push-vuptoqxzwoxx branch March 6, 2026 14:50
@github-actions github-actions Bot mentioned this pull request Mar 6, 2026
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.

Document signature of callbacks registered in AFM model's on("change:{trait}", callback)

2 participants