feat: Add isolate bootstrap helper for Amplify platform channels (#5302) - #7269
Draft
cadivus wants to merge 1 commit into
Draft
feat: Add isolate bootstrap helper for Amplify platform channels (#5302)#7269cadivus wants to merge 1 commit into
cadivus wants to merge 1 commit into
Conversation
Purely additive. No existing file is modified, and the helper is not exported from `amplify_flutter`'s barrel, so single-isolate behaviour is unchanged. A secondary isolate already gets its own isolate-local Amplify state, but no `BinaryMessenger`, so any plugin backed by a platform channel fails there. `ensureAmplifyIsolateInitialized` repairs that from the root isolate's token. Lives in `amplify_flutter` rather than `amplify_core`: `RootIsolateToken` and `BackgroundIsolateBinaryMessenger` come from Flutter, and `amplify_core` is deliberately Flutter-free. Marked `@internal` for now. Promoting it later is additive and non-breaking, whereas shipping it publicly now would commit us under semver before the end-to-end story exists. Two behaviours the helper absorbs so callers do not have to: - No-op on the root isolate. Registering a background messenger there would replace the root isolate's platform message handler. - `amplifyRootIsolateToken` returns null on web. `RootIsolateToken.instance` throws `UnsupportedError` there rather than returning null.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feat/isolate-spike-bg-messenger #7269 +/- ##
===================================================================
+ Coverage 40.98% 41.03% +0.04%
===================================================================
Files 121 122 +1
Lines 8273 8285 +12
Branches 3598 3607 +9
===================================================================
+ Hits 3391 3400 +9
- Misses 4882 4885 +3 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR2 of the #5302 stack, on top of #7266. Purely additive — no existing file modified, not exported from the barrel, so single-isolate behaviour is unchanged.
ensureAmplifyIsolateInitialized(token)/amplifyRootIsolateToken/amplifyIsolateIsInitializedinpackages/amplify/amplify_flutter/lib/src/amplify_isolate.dart. Home isamplify_flutter, notamplify_core:RootIsolateTokenandBackgroundIsolateBinaryMessengerare Flutter types andamplify_coreis deliberately Flutter-free.@internalfor now — promoting later is additive and non-breaking, while shipping it publicly now would commit us under semver before multi-isolate works end to end (the native SDK still rejects a secondconfigure()). Recommend promoting in the PR that lands the broker + docs + example.amplifyRootIsolateTokenreturnsnullon web becauseRootIsolateToken.instancethrowsUnsupportedErrorthere rather than returning null.--platform chromesince this package's CI is VM-only. Top-level functions rather thanAmplifyIsolate.ensureInitializedbecauseamplify_lintsbansavoid_classes_with_only_static_members.