Fixes for Offline mode and Add stableSession mode#150
Open
madhuchavva wants to merge 11 commits intomainfrom
Open
Fixes for Offline mode and Add stableSession mode#150madhuchavva wants to merge 11 commits intomainfrom
madhuchavva wants to merge 11 commits intomainfrom
Conversation
Contributor
Author
|
cursor review |
|
Skipping Bugbot: Bugbot is disabled for this repository. Visit the Bugbot dashboard to update your settings. |
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.
Summary
Introduces two new SDK modes to give apps precise control over when feature-flag updates are applied.
1. Offline Mode
When a pre-fetched payload is passed directly to the builder, the SDK uses it immediately — no network call, no disk round-trip. Call refreshCache() explicitly when you're ready to pick up the latest.
2. Stable Session Mode
With stableSession: true, features are locked at init and will not change for the lifetime of that SDK instance — even if refreshCache() is called or an SSE update arrives. The new payload is written to cache silently and applied on the next cold start.
stableSessionworks withbackgroundSync:trueas well — SSE updates keep the cache warm while the running session stays stable.Changes
Offline mode fix: When
features: Datais provided to the builder, the SDKnow passes the already-parsed features directly to
GrowthBookSDK.init(), skippingthe unnecessary
refreshCache()call and disk round-trip. No network call is madeon init when
backgroundSync: falseand features are supplied.stableSession mode: New
stableSession: Bool = falseflag on both builder inits.When enabled, remote feature fetches (manual
refreshCache()or SSE) are written tocache but not applied to the running SDK. The updated payload is picked up automatically
on next cold start (app restart). The
refreshHandlerstill fires so the developerknows a refresh occurred.
FeaturesViewModel: Added
preloadedFeaturesinit param — skips the cache read inthe constructor when features are already parsed and in memory.
Tests: 4 new tests covering no-network-call on init, immediate feature availability,
stableSession blocking remote apply, and default mode still applying immediately.