How to use the apprun.start 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.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);
  },
}


app.start('my-app', {}, view, update);

document.body.addEventListener('click', e => {
  const t = e.target as HTMLElement;
  if (t.matches('.toggle')) {
    t.classList.toggle('closed');
    t.nextElementSibling && t.nextElementSibling.classList.toggle('collapsed');
  }
});

function pluralize(number, label) {
  if (!number) number = 0;
  return (number === 1) ? number + label : number + label + 's'
}

function timeAgo(time) {
  const between = Date.now() / 1000 - Number(time)

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