Hey folks, I’m trying to figure out how real-time...
# ask-questions
b
Hey folks, I’m trying to figure out how real-time feature updates are working with Flutter? how can I subscribe to the stream or listen to the feature changes?
f
@freezing-postman-69602 any thoughts?
f
Hey... for feature updates, you initialize GrowthBook Instance with
backgroundSync
. Here's an example:
Copy code
final sdk = await GBSDKBuilderApp(
  apiKey: "your_api_key",
  hostURL: "<https://your-growthbook-instance.com>",
  backgroundSync: true, // This enables real-time streaming updates
  growthBookTrackingCallBack: (trackData) {
    // Handle experiment tracking
  },
).initialize();
this establishes an SSE connection to your GrowthBook instance and updates features in real-time.
You can also set a
setRefreshHandler
to log or something in your app to track feature updates.
b
@freezing-postman-69602 I have tried this solution, but the not refreshHandler nor growthBookTrackingCallback callbacks are being fired whenever I enable/disable the feature flags from the dashboard..
f
growthBookTrackingCallback
is for experiment tracking and it will not be fired for feature flag changes. You should see the
refreshHandler
being fired though. Did you notice any connection errors or app errors that may be hindering the feature refreshing process?
w
hey @freezing-postman-69602, i also did check this
refreshHandler
gets fired in 2 cases for me 1. during init and 2. only if if i use
gb?._refresh_();
to manually refresh. my expectation was it should fire when i publish any new changes in an existing or new feature. i don't see any connection related logs getting printed. any thoughts on it?
b
Any updates on this? @freezing-postman-69602
w
@best-rain-36041 try this once on sdk version
3.9.11
should work there, was getting refresh callback on that. but with some changes for another fix after the callback feature value was getting evaluated as null for some reason.
f
heyy.. I have been trying to examine this weird behavior.. I sense an issue in the code.
I'm working on the fix and will keep you in the loop! PS: it took me a bit to get back to you — I was off all last week and came back to a mountain of stuff 😅 Thanks a ton for your patience!
w
sure, no issues.