Skip to content

Instantly share code, notes, and snippets.

const fx = effect => props => [effect, props]
const noop = () => {}
const _abortControllers = {}
export const request = fx(
(
dispatch,
{
@skanne
skanne / hyperapp-reference.md
Last active March 26, 2024 11:09
A reference of Hyperapp 2 actions, effects and subscriptions and how they are declared and used.

Hyperapp 2 – Actions, Effects and Subscriptions

Learn about the function signatures of actions, effects, and subscriptions in Hyperapp 2 and how they are used in apps.

Actions

Actions:

  • Are declared as constant arrow functions (const ActionFunction = (s, p) => ns).
  • Should have names written in PascalCase .
@skanne
skanne / keyCodes.js
Created March 12, 2014 10:47
keyCode object with typical keys
keyCode: {
BACKSPACE: 8
, TAB: 9
, ENTER: 13
, ESCAPE: 27
, SPACE: 32
, PAGE_UP: 33
, PAGE_DOWN: 34
, END: 35
, HOME: 36
@skanne
skanne / devices.js
Created March 12, 2014 10:45
detect mobile devices
var m = navigator.userAgent.match(/(iPhone|iPad|iPod|Android|Windows Phone|BB10|PlayBook)/)
, device = false
if (m && m.length) {
if (/iPhone|iPad|iPod/.test(m[1])) {
device = 'apple'
} else if (/Android/.test(m[1])) {
device = 'android'
} else if (/Windows Phone/.test(m[1])) {
device = 'windows'