0

I am making my first app with React Native, and I have a request that is made as the app starts. However, I don't want to keep the user waiting on that call to finish. However, I need to know if that call has finished by the time the user goes through the on boarding section(5 slides).

If the call isn't over, I'd like to show the user a waiting sign, and if it's over, I'd be using the data(stored in db) to render the next screen.

Not sure what's the best way to do this. In the native app I use events over a bus(EventBus) to let anyone wanting to know of any update. Not sure if redux can help achieve this here, and hence the question.

Here's how the call is happening right now:

fetch('https://example.com/api.json')
  .then((response) => response.json())
  .then((responseJson) => {
    return console.log(responseJson);
  })
  .catch((error) => {
    console.error(error);
  });

In reality I am going to be saving result into a db instead of logging it.

Amit
  • 3,952
  • 7
  • 46
  • 80
  • 2
    With Redux you `dispatch` an action from a component and after it reaches the store(application state) other components interested(subscribed) to store changes will receive the new state as props. Check out *redux* and *redux-thunk* also read https://stackoverflow.com/a/35415559/1005972 – arpl Jun 03 '17 at 22:27
  • Use Redux, Meteor, or a handler to parent component : https://stackoverflow.com/questions/22639534/pass-props-to-parent-component-in-react-js – pirs Jun 04 '17 at 10:25

0 Answers0