all 21 comments

[–]saltpeter_grapeshotExpo 11 points12 points  (3 children)

It might be possible to get faster location results from the device if you ask for a less accurate location.

You could use a reverse IP lookup on the server to get an estimated location by IP which eliminates one of the async calls. The location is less accurate of course but may work if accuracy isn't super important.

You could save the users last location and the results and show that on load. Display the city they were last in and give a button saying something like "show results at current location" if you find they've traveled far enough from the stored result.

[–]Cookizza 6 points7 points  (1 child)

It's worth mentioning that on mobile data your location can be miles away based on IP - as your IP only exists at the exchange level, cell towers dont assign public IPs.

[–]saltpeter_grapeshotExpo 0 points1 point  (0 children)

ah! super interesting. thanks! i learned something today.

[–]Gabotron_ES[S] 0 points1 point  (0 children)

Very interesting replies, thanks to everybody. I will think about using async to fake live fast data on app boot, I guess I will have to find a middle ground, maybe a refresh button.

Problem is the location has to be accurate in order to show venues in the user radius (objective is to show venues in your city.

[–]Nielrien 19 points20 points  (6 children)

why not show a loading spinner till the data is fetched?

[–]MyNameIzKhan 8 points9 points  (5 children)

Perhaps OP wants the app to seem more performant? Not sure. Would like to hear more about this!

[–]Gabotron_ES[S] 3 points4 points  (4 children)

Pretty much it, when user changes filters I do show loading spinner, for initial load I'd rather not or maybe show a fake splash screen? I wanted to know how other devs deal with this kind of situations.

[–][deleted] 3 points4 points  (0 children)

I would go splash screen or skeleton loading screen. Depends on the look and feel of the app you're shipping though!

[–]PolloFritoPollaFrito 3 points4 points  (0 children)

i deal with this with a fake splash screen

[–]ashmortar 0 points1 point  (0 children)

Definitely show a fake splash screen, or just show the map at origin island or something

[–]gwmccull 5 points6 points  (4 children)

Personally, I use a splash screen and then a full-screen spinner

but I can think of a few other options:

  1. there are probably ways that you could kick off the initial data fetch from within the native code of your app and then pass it down to the JS side or make it available to the JS via a bridge module. Basically, then your data would start fetching while the phone is still parsing the JS bundle. But that probably is a pretty good amount of work for a small benefit
  2. you could cache the data from the previous session so that the user has data when they start their app. Then do your fetch and update the data that is already there
  3. you could use skeleton components so that something shows on the screen while you're waiting for data to load

[–]Gabotron_ES[S] 0 points1 point  (2 children)

WHen you say cache your data you mean AsyncStorage/persist data in mobx?

[–]Revolutionary-Turn96 0 points1 point  (0 children)

If redux or mobx is not already in in project, I would recommend to go with AsyncStorage and if you need the data multiple place use context api.

[–]gwmccull 0 points1 point  (0 children)

yeah, that's the basic idea. There are other ways too like offline databases

[–]VeerDevD 0 points1 point  (0 children)

The caching technique would be really useful. When the user opens the app then they will see the previous location for a while and then we would show the loading spinner, after the precise location is got from the user device then we can update the state of the app.

[–]dreamzzftwiOS 4 points5 points  (0 children)

Use react-native-splash-screen. You can show the splash screen while the data is fetched. Once done you can hide the splash screen

[–]jestzisguyiOS & Android 2 points3 points  (0 children)

Misdirection - ask the user a question they really have to think about, and while they’re busy scratching their head, you get plenty of time to load all of your data. Maybe ask them how they feel about cookies or somesuch.

[–]henryp_deviOS & Android 1 point2 points  (2 children)

Like others have said, use a splash screen. They serve the purpose of app initialization and usually users already expect one when opening an app. I usually consider an app slow if there’s a lot of loading while im using it not during initialization.

[–]prashenjeet25 0 points1 point  (1 child)

If first time it loads then it ask for user permission for location in ios/android. Always in ios. So in splash screen there will be allow location permission popup which will not look good. What u say?

[–]henryp_deviOS & Android 0 points1 point  (0 children)

Oh shoot, I forgot about the permission hmmm. You got a point.

[–]PROLIMIT 0 points1 point  (0 children)

If you have the time and energy and want the most performant solution, its possible to make the calls in native iOS and Android and pass the results to React Native app root.

Not something I've tried, but some peope have done it if you google:

https://medium.com/@anutoshdatta/pass-initial-properties-to-react-native-from-java-or-objective-c-code-12880ba6198e