This commit is contained in:
travis 2016-03-17 10:44:47 -07:00
Родитель 5cf22565d0
Коммит 1471f451cd
2 изменённых файлов: 18 добавлений и 23 удалений

Просмотреть файл

@ -8,14 +8,16 @@ import type {Address, DOM} from "reflex"
*/
const Increment =
{ type: "Increment"
, create: () => Increment
}
() =>
( { type: "Increment"
}
)
const Decrement =
{ type: "Decrement"
, create: () => Decrement
}
() =>
( { type: "Decrement"
}
)
export const init =
(value/*:number*/)/*:Model*/ =>
@ -25,18 +27,18 @@ export const update =
( model/*:Model*/
, action/*:Action*/
)/*:Model*/ =>
( action.type === Increment.type
( action.type === "Increment"
? { value: model.value + 1 }
: action.type === Decrement.type
: action.type === "Decrement"
? { value: model.value - 1 }
: model
)
const counterStyle = {
value: {
fontWeight: "bold"
const counterStyle =
{ value:
{ fontWeight: "bold"
}
}
}
export const view =
@ -48,7 +50,7 @@ export const view =
}
, [ html.button
( { key: "decrement"
, onClick: forward(address, Decrement.create)
, onClick: forward(address, Decrement)
}
, ["-"]
)
@ -60,7 +62,7 @@ export const view =
)
, html.button
( { key: "increment"
, onClick: forward(address, Increment.create)
, onClick: forward(address, Increment)
}
, ["+"]
)

Просмотреть файл

@ -2,22 +2,15 @@
import type {Address, DOM} from "reflex"
type Tag <type> =
{ type: type
}
export type Model =
{ value: number
}
export type Action
= Tag<"Increment">
| Tag<"Decrement">
= {type: "Increment"}
| {type: "Decrement"}
declare export var Increment:Tag<"Increment">
declare export var Decrement:Tag<"Decrement">
declare export function init (value:number):
Model