How to use the hyperapp.app function in hyperapp

To help you get started, we’ve selected a few hyperapp 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 LearnHyperapp / hyperapp-recipes / logger.js View on Github external
const actions = {
  down: () => state => ({ count: state.count - 1 }),
  up: () => state => ({ count: state.count + 1 })
};

const view = (state, actions) =>
  // logs the state before each render
  console.log(state) && (
    <main>
      <h1>{state.count}</h1>
      <button>-</button>
      <button>+</button>
    </main>
  );

const main = app(state, actions, view, document.body);
github pedrouid / hyperapp-boilerplate / src / app.js View on Github external
import { h, app } from 'hyperapp'; // eslint-disable-line
import home from './pages/home';
import { INITIAL_STATE, actions } from './actions';
import './index.css';

app(INITIAL_STATE, actions, home, document.body);
github kwasniew / hyperapp-realworld-example-app / src / app.js View on Github external
const initState = set(userLens, sessionRepository.load(), DEFAULT_STATE);

  const actions = {
    location: locationModule.actions,
    ...editorActions,
    ...articleActions,
    ...settingsActions,
    ...authActions,
    ...articlesActions,
    ...profileActions,
    ...sharedActions,
    ...routerActions
  };

  // const main = withLogger(app)(initState, actions, view, document.body)
  const main = app(initState, actions, view, document.body);

  const unsubscribe = locationModule.subscribe(main.location);
  addEventListener("popstate", () => main.setRoute(location.pathname));
  main.loadPage(location.pathname);
  sessionRepository.onChange(main.setUser);

  return { main, unsubscribe };
}
github frenzzy / minesweeper / src / index.js View on Github external
import { app } from 'hyperapp'
import { state, actions, view } from './app'

window.app = app(state, actions, view, document.getElementById('app'))

if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('service-worker.js');
}

// Enable hot module replacement
// https://webpack.js.org/concepts/hot-module-replacement/
if (module.hot) {
  let prevState = state
  module.hot.accept('./app', () => {
    const prevApp = window.app
    const currState = prevApp.getState()
    prevApp.destroy()
    const prevContainer = document.getElementById('app')
    const nextContainer = prevContainer.cloneNode(false)
    prevContainer.parentNode.appendChild(nextContainer)
github kewitz / dat-medium / app / app.js View on Github external
import { app } from 'hyperapp'
import actions from 'actions'
import state from 'state'
import view from 'view'

import 'style/style.css'

app({ state, view, actions }).init()
github neatsoftware / term-sheets / src / index.js View on Github external
restart: () => (state, actions) => {
    const commands = state.commands
    actions.updateCommands([])
    setTimeout(() => actions.updateCommands(commands))
  },
  export: () => (state, actions) => {
    actions.updateIsExporting(true)
    return exportProject(state)
      .catch(alert)
      .then(() => actions.updateIsExporting(false))
  }
}

const view = (state, actions) => h(appView, Object.assign(state, actions))

export default app(state, actions, view, document.body)
github soenkekluth / hyperapp-example / src / index.js View on Github external
<h1>hyperapp counter</h1>
    <output>{state.count}</output>
    {Button({ label: '-', action: actions.down, disabled: state.count &lt;= 0 })}
    {SimpleButton('+', actions.up)}
    {Article({
      text: state.action,
      'data-atributes': 'work',
      style: { color: 'inherit' },
    })}
    <button>save</button>
    <button>clear</button>
    <footer>{state.saved !== null &amp;&amp; <p>saved: {state.saved}</p>} </footer>
  
);

const counter = app(state, actions, View, document.body);
window.counter = counter;
github krausest / js-framework-benchmark / frameworks / non-keyed / hyperapp / src / index.js View on Github external
<table class="table table-hover table-striped test-data">
                <tbody>
                    </tbody>
            </table>
            <span aria-hidden="true" class="preloadicon glyphicon glyphicon-remove">
        
    )
}

app(state, actions, view, document.getElementById("main"))
</span>
github jc21 / docker-registry-ui / src / frontend / js / index.js View on Github external
'gray-light':         '#aab0b6',
        'gray-lighter':       '#dbdde0',
        'gray-lightest':      '#f3f4f5',
        'gray-dark':          '#343a40',
        'gray-dark-darkest':  '#0a0c0d',
        'gray-dark-darker':   '#15171a',
        'gray-dark-dark':     '#2a2e33',
        'gray-dark-light':    '#717579',
        'gray-dark-lighter':  '#c2c4c6',
        'gray-dark-lightest': '#ebebec'
    }
};

import tabler from 'tabler-core';

const main = app(
    state,
    actions,
    router,
    document.getElementById('app')
);

location.subscribe(main.location);

main.bootstrap();
setInterval(main.bootstrap, 30000);
github lukejacksonn / hyperapp-pwa / src / index.js View on Github external
reset: () =&gt; ({ count: 0 }),
  sum: data =&gt; ({ count }) =&gt; ({ count: count + data }),
}

const view = (state, actions) =&gt; (
  <main>
    <h1>{state.count}</h1>
    <div>
      <button> actions.sum(-1)}&gt;Sub</button>
      <button> actions.reset()}&gt;Reset</button>
      <button> actions.sum(1)}&gt;Add</button>
    </div>
  </main>
)

app(state, actions, view, document.body)

hyperapp

The tiny framework for building hypertext applications.

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis

Popular hyperapp functions