expo-refresh - #189
Open
Makisuo wants to merge 4 commits into
Open
expo-refresh#189Makisuo wants to merge 4 commits into
Makisuo wants to merge 4 commits into
Conversation
commit: |
# Conflicts: # src/SuperwallExpoModule.ts
Address review feedback: the dev-only refresh effect read isLoading and configurationError from a ref while depending only on [isConfigured]. If isConfigured flips true in one render before isLoading clears in a later (unbatched) render, the effect ran while isLoading was still true and bailed out, silently skipping the refresh. Read both values reactively and add them to the dependency array so the effect re-evaluates once they settle. The hasObservedConfiguredRef guard still prevents spurious calls, so no extra refreshes are introduced. Removes the now-unused refreshStateRef. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# Conflicts: # src/__tests__/sdk.behavior.test.tsx
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.
Greptile Summary
This PR adds a
refreshConfigurationnative function (iOS + Android) and wires it up inSuperwallProviderso that, in development mode, the Superwall SDK configuration is automatically refreshed after Metro/Fast Refresh cycles — avoiding the need for a full app restart to pick up dashboard config updates.Confidence Score: 5/5
Safe to merge — all findings are P2 style suggestions with no correctness impact on the Metro-refresh path.
The core feature is logically correct and well-guarded by the DEV flag and the initial-observe skip. All remaining comments are P2: the iOS promise never-reject is benign for the current fire-and-forget caller, and the stale-ref edge case requires two separate non-batched state updates in a Metro refresh scenario (unlikely in practice). The test suite is thorough and covers the key behavioural contracts.
src/SuperwallProvider.tsx (stale-ref guard), ios/SuperwallExpoModule.swift (missing reject path)
Important Files Changed
hasObservedConfiguredRef/refreshStateRefsnapshot pair; readsisLoadingandconfigurationErrorfrom a render-snapshot ref inside an[isConfigured]-only effect, which can silently skip a refresh if those fields are updated in a later render.refreshConfigurationasync function; resolves promise inside the completion closure but has no error path — the promise always resolvesnilregardless of whether the SDK encountered an error.refreshConfigurationasync function that calls the Android SDK synchronously and resolves the promise immediately, with proper error rejection on Throwable.refreshConfiguration(): Promise<void>to the native module declaration; minor reformatting ofdidHandleCustomCallbacksignature.refreshConfiguration.Sequence Diagram
sequenceDiagram participant Metro as Metro (Fast Refresh) participant SW as SuperwallProvider participant Ref as refreshStateRef / hasObservedConfiguredRef participant Native as SuperwallExpoModule (native) participant SDK as SuperwallKit / Android SDK Note over SW: App starts — initial configure() SW->>Ref: hasObservedConfiguredRef = false SDK-->>SW: isConfigured → true SW->>Ref: hasObservedConfiguredRef = true (skip refresh) Note over Metro: Developer triggers Fast Refresh Metro->>SDK: SDK re-initialises SDK-->>SW: isConfigured → false SDK-->>SW: isConfigured → true SW->>Ref: Read refreshStateRef (isLoading=false, configError=null) SW->>Ref: hasObservedConfiguredRef already true → proceed SW->>Native: refreshConfiguration() Native->>SDK: Superwall.shared.refreshConfiguration (iOS callback) / Superwall.instance.refreshConfiguration() (Android sync) SDK-->>Native: done Native-->>SW: Promise resolvesPrompt To Fix All With AI
Reviews (1): Last reviewed commit: "expo-refresh" | Re-trigger Greptile