react-native-simple-router icon indicating copy to clipboard operation
react-native-simple-router copied to clipboard

Option to warm up the next route

Open ericraio opened this issue 9 years ago • 15 comments

I currently have a welcome screen where 8 out of 10 times, they are going to click on a specific button.

A web browser has the ability to pre-load the next route and render the page in the background.

It would be nice if i could some how pre-load the next "toRoute" matching a specific criteria so when the user taps on the button, the next page is already loaded with data and can make the app feel snappier in the beginning.

ericraio avatar Apr 04 '16 23:04 ericraio

I like that !

charpeni avatar Apr 05 '16 12:04 charpeni

@Eric: Do you have an idea on how that could be implmented? I'd love to help you get that done.

On Tue, Apr 5, 2016 at 2:48 PM Nicolas Charpentier [email protected] wrote:

I love that !

— You are receiving this because you are subscribed to this thread.

Reply to this email directly or view it on GitHub https://github.com/react-native-simple-router-community/react-native-simple-router/issues/110#issuecomment-205783932

davidLeonardi avatar Apr 05 '16 12:04 davidLeonardi

@sethx I'm not quite sure how to implement this but I think it might be a similar concept when you have a route stack and you are "swipping" to go back and you can already see the previous screen layered underneath, I think navigator handles this but would need to look at the source code and reverse engineer it going the other direction

ericraio avatar Apr 06 '16 01:04 ericraio

I think we maybe able to achieve this with prop initialRouteStack or method immediatelyResetRouteStack(routeStack).

initialRouteStack [object]

Provide a set of routes to initially mount. Required if no initialRoute is provided. Otherwise, it will default to an array containing only the initialRoute

Navigator API provide methods to navigate to an existing scene without unmounting :

jumpBack() - Jump backward without unmounting the current scene jumpForward() - Jump forward to the next scene in the route stack jumpTo(route) - Transition to an existing scene without unmounting

I guess jumpTo will do the same thing as swiping back to the previous route.

We could pre-render or warm up most used scenes and navigate with jumpTo(). Also, I think we should add a method that acts like jumpTo() but that also move the scene to the end of the route stack. Alternatively, a method that jumpTo and push to the end of the route stack if scene is already mounted OR push that new scene if it doesn't exist would be interesting too.

Thoughts?

charpeni avatar Apr 06 '16 13:04 charpeni

@charpeni great find! That seems like it would work. From an interface perspective. I was thinking I could call a function in the componentDidMount where I can preload a route and the next time "toRoute" is called matching a preloaded scene, it would go to the mounted scene instead of mounting another.

In my welcome screen, if they don't hit "Start" for an example and the start button goes to the Home Screen, at some point they will land at Home and I would like it to be loaded and ready.

What do ya think?

ericraio avatar Apr 06 '16 21:04 ericraio

Nice perspective, I have the same use case as I need to pre-render a WebView to avoid the waiting of the user while loading.

It would go to the mounted scene instead of mount another.

It should push that existing scene to the end of the route stack to be able to back to the previous scene.

charpeni avatar Apr 07 '16 13:04 charpeni

@charpeni yeah that makes sense

ericraio avatar Apr 07 '16 18:04 ericraio

@charpeni are you able to start this? I can help out where needed

ericraio avatar Apr 08 '16 15:04 ericraio

I can't start this right now, I have other priorities to deal with but I'll need it in a few weeks, so I'll keep you up-to-date. Feel free to look at it if you have time :)

charpeni avatar Apr 08 '16 15:04 charpeni

@charpeni yeah same here, i should be able to look into this in a week or 2

ericraio avatar Apr 08 '16 15:04 ericraio

@sethx ? :D

charpeni avatar Apr 08 '16 15:04 charpeni

I might give it a shot this week, my workload is decreasing so i have some time On Fri, 8 Apr 2016 at 17:40, Nicolas Charpentier [email protected] wrote:

@sethx https://github.com/sethx ? :D

— You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub https://github.com/react-native-simple-router-community/react-native-simple-router/issues/110#issuecomment-207484332

davidLeonardi avatar Apr 09 '16 18:04 davidLeonardi

@sethx hey seth, were you able to get a chance to look at this? :)

ericraio avatar Apr 13 '16 22:04 ericraio

Ive been sick all week unfortunately. Hopefully i feel better soon! On Thu, 14 Apr 2016 at 00:20, Eric Raio [email protected] wrote:

@sethx https://github.com/sethx hey seth, were you able to get a chance to look at this? :)

— You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub https://github.com/react-native-simple-router-community/react-native-simple-router/issues/110#issuecomment-209672455

davidLeonardi avatar Apr 14 '16 10:04 davidLeonardi

@sethx get well soon!! :100:

ericraio avatar Apr 14 '16 20:04 ericraio