lion/packages/ajax/stories/index.stories.js
Thomas Allmer 4a93599228 chore: update storybook version
Co-authored-by: Joren Broekema <Joren.Broekema@ing.com>
2020-01-13 13:58:03 +01:00

77 lines
1.9 KiB
JavaScript

import { html, storiesOf } from '@open-wc/demoing-storybook';
import { ajax, AjaxClass } from '../index.js';
storiesOf('Ajax system|Ajax')
.addParameters({ options: { selectedPanel: 'storybook/actions/actions-panel' } })
.add(
'Get',
() => html`
<button
@click=${() => {
ajax
.get('./dummy-jsons/peter.json')
.then(response => {
console.log(response.data);
})
.catch(error => {
console.log(error);
});
}}
>
Log Get Request to Action Logger
</button>
`,
)
.add(
'Cancelable',
() => html`
<button
@click=${() => {
const myAjax = AjaxClass.getNewInstance({ cancelable: true });
requestAnimationFrame(() => {
myAjax.cancel('too slow');
});
myAjax
.get('./dummy-jsons/peter.json')
.then(response => {
console.log(response.data);
})
.catch(error => {
console.log(error);
});
}}
>
Execute Request to Action Logger
</button>
`,
)
.add(
'CancelPreviousOnNewRequest',
() => html`
<button
@click=${() => {
const myAjax = AjaxClass.getNewInstance({ cancelPreviousOnNewRequest: true });
myAjax
.get('./dummy-jsons/peter.json')
.then(response => {
console.log(response.data);
})
.catch(error => {
console.log(error.message);
});
myAjax
.get('./dummy-jsons/max.json')
.then(response => {
console.log(response.data);
})
.catch(error => {
console.log(error.message);
});
}}
>
Execute 2 Request to Action Logger
</button>
`,
);