Alternative way to make appMachine spawned children type safe#5890
Alternative way to make appMachine spawned children type safe#5890franknoirot merged 4 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
QA Wolf here! As you write new code it's important that your test coverage is keeping up. |
| export const authActor = appActor.system.get(AUTH) as ActorRefFrom< | ||
| typeof authMachine | ||
| > | ||
| export const authActor = appActor.getSnapshot().children.auth! |
There was a problem hiding this comment.
Casting is safe here because, when the state snapshot is available, appMachine will have already initialized all spawned children.
There was a problem hiding this comment.
Nice. If these were invoked actors we'd have to be more cautious with the cast here, or if they were spawned in a more ephemeral way? I just want us to remember that if we make use of other patterns as we break apart the modeling machine, for example.
There was a problem hiding this comment.
Yes, if they were invoked, they'd legitimately be available partially depending on the state. Even spawned actors can be partially unavailable too. It's safe here because we have child actors that are spawned in the root state in the entry action meaning it's the first action that runs before the the first state transition happens in the machine so in other words, these spawns are always available.
There was a problem hiding this comment.
Thanks, I added a "gotcha" comment here
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5890 +/- ##
==========================================
+ Coverage 85.37% 85.39% +0.02%
==========================================
Files 110 110
Lines 44198 44198
==========================================
+ Hits 37733 37743 +10
+ Misses 6465 6455 -10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
franknoirot
left a comment
There was a problem hiding this comment.
Thanks for looking into this @farskid
7028b9f to
e9ce87a
Compare
* origin/main: (26 commits) attempt to import win-ca on windows (#6136) Upgrade e2e-tests windows runner from 4 cores to 8 (#6166) Follow-up fixes after bearing sample rename (#6164) Add test for #5799: "Only showing axis planes when there are no errors" (#6007) Wait for export button to make test more reliable (#6143) sketching on a mirror2d thats been extruded fixed! (#6149) Bump vite from 5.4.16 to 5.4.17 in /packages/codemirror-lang-kcl in the security group (#6150) Bump vite from 5.4.16 to 5.4.17 in the security group (#6151) Update all KCL-Samples to be more ME friendly (#6132) Shorten feedback cycle for legitimate failures (#6146) Remove the camera projection toggle from the UI (#6077) Use all available CPUs to run tests on CI (#6138) [fix] Get rid of risky useEffect in restart onboarding flow (#6133) Feature: Traditional menu actions in desktop application part II (#6030) [Bug] fix some UI friction from imports (#6139) Use scene fixture to make test more reliable on macOS (#6140) Fix: function composition during playwright setup created a massive page.reload loop (#6137) Alternative way to make appMachine spawned children type safe (#5890) [BUG] mutate ast to keep comments for pipe split ast-mod (#6128) Rename the app to Zoo Design Studio (#5974) ...
This is not perfect but because spawned children are direct children of the appMachine, we don't really use nor do we need any of the system properties here. They're direct children and can be typed strongly.