Simple and reorganized version of http://www.w3.org/2014/07/mobile-web-app-state/
Community
- System Applications Working Group
http://www.w3.org/2012/05/sysapps-wg-charter.html
- Device APIs Working Group
Simple and reorganized version of http://www.w3.org/2014/07/mobile-web-app-state/
Community
- System Applications Working Group
http://www.w3.org/2012/05/sysapps-wg-charter.html
type product = { | |
category: string, | |
price: string, | |
stocked: bool, | |
name: string | |
}; | |
type products = list(product); | |
let products = [ |
/* `action` and `state` types must be defined before the `let component` statement for type inference to work */ | |
type action = | |
| UpdateEmail string | |
| UpdatePassword string; | |
type state = { | |
email: string, | |
password: string | |
}; |
/* ========================================================== | |
* | |
* Log on a remote server most of the errors in the browser | |
* | |
* @author Chris Cinelli | |
* | |
* Depends on: | |
* stacktrace.js - https://github.com/eriwen/javascript-stacktrace | |
* jsonStringify.js - http://www.thomasfrank.se/json_stringify_revisited.html | |
* |
/** | |
* An implementation for Quicksort. Doesn't | |
* perform as well as the native Array.sort | |
* and also runs the risk of a stack overflow | |
* | |
* Tests with: | |
* | |
* var array = []; | |
* for(var i = 0; i < 20; i++) { | |
* array.push(Math.round(Math.random() * 100)); |
:root { | |
--my-width: 400px; | |
} | |
:export { | |
myWidth: var(--my-width); | |
} | |
.myClass { | |
width: var(--my-width); |
type validation('a) = | |
| NotEmpty | |
| Custom('a); | |
type t = string; | |
let validate = (rule, value, values) => | |
switch (rule) { | |
| NotEmpty => String.length(value) > 0 | |
| Custom(fn) => fn(value, values) |
import React, { Component } from 'react'; | |
import { createStore, combineReducers, applyMiddleware, bindActionCreators } from 'redux'; | |
import { provide, connect } from 'react-redux'; | |
import thunk from 'redux-thunk'; | |
const AVAILABLE_SUBREDDITS = ['apple', 'pics']; | |
// ------------ | |
// reducers | |
// ------------ |
let recv = (client, maxlen) => { | |
let bytes = Bytes.create(maxlen); | |
let len = Unix.recv(client, bytes, 0, maxlen, []); | |
Bytes.sub_string(bytes, 0, len) | |
}; | |
let parse_top = top => { | |
let parts = Str.split(Str.regexp("[ \t]+"), top); | |
switch (parts) { |
module Store = { | |
type action = | |
| Increase | |
| Decrease | |
| SetUsername(string); | |
type state = { | |
count: int, | |
username: string, | |
}; | |
type storeBag = { |