Start pre-loading and cache data at Slash Screen

Hi, I’ve recently completed the hikr tutorial app (really nice tutorial by the way!). I thought it would be interesting to add a new feature to it, but I’m not sure where to start:

I’d like to initiate the call to retrieve current hikes from the backend at the splash page before the user navigates to the main page. When the user actually opens the home page from the splash screen, I’d like to just let this process continue (if it’s not done yet) until the new items have been retrieved.

Any tips would be appreciated!

I think I may have figured this out on my own. Here’s what I’m doing:

In SplashPage.js, I’ve added the following code:

var Lifecycle = require('FuseJS/Lifecycle');

var Context = require("Modules/Context");

Lifecycle.on("enteringInteractive", function() {
	console.log("loading hikes...");
	Context.loadHikes();
});

And in Context.js, I’ve moved the loading code into loadHikes instead of running it automatically when the module is executed:

function loadHikes() {
	Backend.getHikes()
	.then(function(newHikes) {
		hikes.replaceAll(newHikes);
	})
	.catch(function(error) {
		console.log("Couldn't get hikes: " + error);
	});	
}

Important to remember to add loadHikes to the module.exports as well:

module.exports = {
    loadHikes: loadHikes, //added

    hikes: hikes,

    updateHike: updateHike
};