Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'#': (state, type, id) => {
type = type || 'top';
state.type = type;
state[type] = state[type] || { min: 0, max: page_size, items: [] };
state.id = id;
if (type === 'item')
app.run('get-item', id, state);
else
app.run('get-list', type, state[type]);
},
'render': state => state,
const fetchListItems = async ({ items, min, max }) => {
await Promise.all(items.map(async (id, idx) => {
if (idx >= min && idx < max && (typeof id === 'number')) {
items[idx] = await fetch(`item/${id}`)
}
}));
app.run('render');
}
if (list.items.length) {
'#': (state, type, id) => {
type = type || 'top';
state.type = type;
state[type] = state[type] || { min: 0, max: page_size, items: [] };
state.id = id;
if (type === 'item')
app.run('get-item', id, state);
else
app.run('get-list', type, state[type]);
},
'render': state => state,
'more': state => {
const list = state[state.type];
list.max = Math.min(list.max + page_size, list.items.length)
app.run('get-list', state.type, list);
},
}
{list.items && list.max < list.items.length && <a> app.run('more')}> | More ...</a>}