How to use the apprun.run function in apprun

To help you get started, we’ve selected a few apprun examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yysun / apprun-hn / src / hacker-news.tsx View on Github external
'#': (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,
github yysun / apprun-hn / src / api.ts View on Github external
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) {
github yysun / apprun-hn / src / hacker-news.tsx View on Github external
'#': (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,
github yysun / apprun-hn / src / hacker-news.tsx View on Github external
'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);
  },
}
github yysun / apprun-hn / src / hacker-news.tsx View on Github external
      {list.items &amp;&amp; list.max &lt; list.items.length &amp;&amp; <a> app.run('more')}&gt; |&nbsp; More ...</a>}

apprun

JavaScript library that has Elm inspired architecture, event pub-sub and components

MIT
Latest version published 4 months ago

Package Health Score

62 / 100
Full package analysis