Skip to content

fix(ios): bind the view model instance when creating the state machine - #415

Open
mfazekas wants to merge 3 commits into
mainfrom
claude/fix-414-ios-script-binding
Open

mfazekas wants to merge 3 commits into
mainfrom
claude/fix-414-ios-script-binding

Conversation

@mfazekas

@mfazekas mfazekas commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

On the iOS new runtime the state machine was created before dataBind was resolved, so a script that caches context:viewModel() in init kept the file's default instance instead of the one passed as dataBind. The state machine is now created after binding resolution, with the instance passed via createStateMachine(name, binding:). This covers both instance and by-name binding. Android is unaffected.

script-databinding.harness.tsx covers it with the reporter's fixture: on main the script reports isReady 0 / observedSeed 0, with the fix 1 / 42. The Issue414ScriptBinding reproducer page shows the same as a red/green square.

Not covered: DataBindMode.Auto still creates the state machine without an instance, and swapping dataBind on a mounted view still rebinds the existing state machine. The latter belongs with #403.

Closes #414

Fails on main with isReady 0 / observedSeed 0; replaces the code comment.
@mfazekas
mfazekas force-pushed the claude/fix-414-ios-script-binding branch from df8b0dd to bcf05a1 Compare October 9, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working iOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] Script init caches the wrong view model when dataBind is applied after state-machine creation

1 participant