Hello! Are there examples to enable streaming of ...
# ask-questions
c
Hello! Are there examples to enable streaming of events on React Native/Expo? I feel the documentation for
setPolyfills
is not very good.
Copy code
const storage = new MMKV();

setPolyfills({
  // Required when using built-in feature loading and Node 17 or lower
  fetch: require("react-native-fetch-polyfill"),
  // Optional, can make feature rollouts faster
  EventSource: require("react-native-event-source"),
  // Optional, can reduce startup times by persisting cached feature flags
  localStorage: {
    // Example using Redis
    getItem: (key) => storage.getString(key) ?? null,
    setItem: (key, value) => storage.set(key, value),
  },
});
This does not seem to work, it does not fetch any flags (every flag is off/undefined)
if I set any polyfills it will stop working
w
@creamy-piano-53628 I'm having the same problem - did you find a solution?
c
@wide-cpu-11577 not yet 🙁
f
Hi folks
sorry for the delay
is it streaming realtime updates thats the problem, or just getting it to work in general?
w
@fresh-football-47124 Thanks for reaching out! Everything besides the realtime/streaming functionality works on my end. Currently as a workaround I'm just refreshing the features after resumed app activity. Any advice on how to get the realtime/streaming functionality working? I have not configured any polyfills in our project yet.
c
@fresh-football-47124 streaming does not work. The initial state is fetched correctly, but a manual refresh is needed to get the new state. The polyfills documentation is not very good for React Native.
CleanShot 2024-04-26 at 09.49.14@2x.png
Copy code
const storage = new MMKV();

setPolyfills({
  // Required when using built-in feature loading and Node 17 or lower
  fetch: require("react-native-fetch-polyfill"),
  // Optional, can make feature rollouts faster
  EventSource: require("react-native-event-source"),
  // Optional, can reduce startup times by persisting cached feature flags
  localStorage: {
    // Example using Redis
    getItem: (key) => storage.getString(key) ?? null,
    setItem: (key, value) => storage.set(key, value),
  },
});
I tried this, but it does not work. It should be simple to setup, we just need the correct params for the polyfills.