const { success, failure, notAsked, loading, map, fold } = require('dataway');
// => Success ['MR', 'WILSON']
const render = dataway => fold(
() => "<p>Click on the load button</p>",
() => "<p>Loading</p>",
error => `<p>something wrong did happen : ${error}</p>`,
success => `<p>${success}</p>`,
dataway
);
render(success('Mr Wilson'));
// => <p>Mr Wilson</p>
render(failure('Ooops failed to fetch Mr Wilson data'));
// => <p>something wrong did happen : Ooops failed to fetch Mr Wilson data</p>
render(notAsked);
// => '<p>Click on the load button</p>'
render(loading);
// => '<p>Loading</p>'