src/index.js
function start(cfg = {}) {
	if (started) {
		console.warn('Application already started, cannot call start again.');
		return;
	}

    initLibraries(cfg);
	initAppHandlers(cfg);
    // if already bootloaded somewhere
    // immediately call the onLaunch method
    if (cfg.bootloaded) {
        App.onLaunch(App.launchOptions);
    }
	started = true;
}
function start(cfg = {}) {
	if (started) {
		console.warn('Application already started, cannot call start again.');
		return;
	}

    initLibraries(cfg);
	initAppHandlers(cfg);
    // if already bootloaded somewhere
    // immediately call the onLaunch method
    if (cfg.bootloaded) {
        App.onLaunch(App.launchOptions);
    }
	started = true;
}
function start ( cfg = { } ) { if ( started ) { console . warn ( 'Application already started, cannot call start again.' ) ; return ; } initLibraries ( cfg ) ; initAppHandlers ( cfg ) ; // if already bootloaded somewhere // immediately call the onLaunch method if ( cfg . bootloaded ) { App . onLaunch ( App . launchOptions ) ; } started = true ; }
Starts the Apple TV application after applying the relevant configuration options

@example
// create your pages
let SearchPage = ATV.Page.create({ page configurations });
let HomePage = ATV.Page.create({ page configurations });
let MoviesPage = ATV.Page.create({ page configurations });
let TVShowsPage = ATV.Page.create({ page configurations });
let LoginPage = ATV.Page.create({ page configurations });

// template functions
const loaderTpl = (data) => `<document>
<loadingTemplate>
<activityIndicator>
<title>${data.message}</title>
</activityIndicator>
</loadingTemplate>
</document>`;

const errorTpl = (data) => `<document>
<descriptiveAlertTemplate>
<title>${data.title}</title>
<description>${data.message}</description>
</descriptiveAlertTemplate>
</document>`;

// Global TVML styles
let globalStyles = `
.text-bold {
font-weight: bold;
}
.text-white {
color: rgb(255, 255, 255);
}
.dark-background-color {
background-color: #091a2a;
}
.button {
background-color: rgba(0, 0, 0, 0.1);
tv-tint-color: rgba(0, 0, 0, 0.1);
}
`;

// start your application by passing configurations
ATV.start({
style: globalStyles,
menu: {
attributes: {},
items: [{
id: 'search',
name: 'Search',
page: SearchPage
}, {
id: 'homepage',
name: 'Home',
page: HomePage,
attributes: {
autoHighlight: true // auto highlight on navigate
}
}, {
id: 'movies',
name: 'Movies',
page: MoviesPage
}, {
id: 'tvshows',
name: 'TV Shows',
page: TVShowsPage
}]
},
templates: {
// loader template
loader: loaderTpl,
// global error template
error: errorTpl,
// xhr status based error messages
status: {
'404': () => errorTpl({
title: '404',
message: 'The given page was not found'
}),
'500': () => errorTpl({
title: '500',
message: 'An unknown error occurred, please try again later!'
})
}
},
// global event handlers that will be called for each of the pages
handlers: {
select: {
globalSelecthandler(e) {
let element = e.target;
let someElementTypeCheck = element.getAttribute('data-my-attribute');

if (elementTypeCheck) {
// perform action
}
}
}
},
onLaunch(options) {
// navigate to menu page
ATV.Navigation.navigateToMenuPage();
// or you can navigate to previously created page
// ATV.Navigation.navigate('login');
}
});

@inner
@alias module:ATV.start
@fires onLaunch

@param  {Object} cfg 		Configuration options
Starts the Apple TV application after applying the relevant configuration options