├── examples
├── ReactNativeDemo
│ ├── .watchmanconfig
│ ├── .babelrc
│ ├── android
│ │ ├── settings.gradle
│ │ ├── app
│ │ │ ├── src
│ │ │ │ └── main
│ │ │ │ │ ├── res
│ │ │ │ │ ├── values
│ │ │ │ │ │ ├── strings.xml
│ │ │ │ │ │ └── styles.xml
│ │ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ └── mipmap-xxhdpi
│ │ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── java
│ │ │ │ │ └── com
│ │ │ │ │ │ └── reactnativedemo
│ │ │ │ │ │ ├── MainActivity.java
│ │ │ │ │ │ └── MainApplication.java
│ │ │ │ │ └── AndroidManifest.xml
│ │ │ ├── BUCK
│ │ │ ├── proguard-rules.pro
│ │ │ └── build.gradle
│ │ ├── gradle
│ │ │ └── wrapper
│ │ │ │ ├── gradle-wrapper.jar
│ │ │ │ └── gradle-wrapper.properties
│ │ ├── keystores
│ │ │ ├── debug.keystore.properties
│ │ │ └── BUCK
│ │ ├── build.gradle
│ │ ├── gradle.properties
│ │ ├── gradlew.bat
│ │ └── gradlew
│ ├── .buckconfig
│ ├── __tests__
│ │ ├── index.ios.js
│ │ └── index.android.js
│ ├── ios
│ │ ├── ReactNativeDemo
│ │ │ ├── AppDelegate.h
│ │ │ ├── main.m
│ │ │ ├── Images.xcassets
│ │ │ │ └── AppIcon.appiconset
│ │ │ │ │ └── Contents.json
│ │ │ ├── AppDelegate.m
│ │ │ ├── Info.plist
│ │ │ └── Base.lproj
│ │ │ │ └── LaunchScreen.xib
│ │ ├── ReactNativeDemoTests
│ │ │ ├── Info.plist
│ │ │ └── ReactNativeDemoTests.m
│ │ └── ReactNativeDemo.xcodeproj
│ │ │ ├── xcshareddata
│ │ │ └── xcschemes
│ │ │ │ └── ReactNativeDemo.xcscheme
│ │ │ └── project.pbxproj
│ ├── .gitignore
│ ├── package.json
│ ├── index.ios.js
│ ├── index.android.js
│ └── .flowconfig
├── hello
│ ├── .babelrc
│ ├── index.html
│ ├── index.js
│ ├── webpack.config.js
│ └── package.json
├── http
│ ├── .babelrc
│ ├── index.html
│ ├── webpack.config.js
│ ├── package.json
│ └── index.js
├── time
│ ├── .babelrc
│ ├── index.html
│ ├── webpack.config.js
│ ├── package.json
│ └── index.js
├── simple-todos
│ ├── .babelrc
│ ├── index.html
│ ├── webpack.config.js
│ ├── package.json
│ └── index.js
├── counter
│ ├── index.html
│ ├── webpack.config.js
│ ├── Counter.js
│ ├── index.js
│ └── package.json
└── counter-pair
│ ├── index.html
│ ├── webpack.config.js
│ ├── Counter.js
│ ├── index.js
│ ├── package.json
│ └── CounterPair.js
├── .gitignore
├── .babelrc
├── .npmignore
├── index.js
├── src
├── native.js
├── util.js
├── index.js
├── config.js
├── view.js
├── type-system.js
├── program.js
└── component.js
├── native.js
├── index.html
├── .flowconfig
├── webpack.config.js
├── app
├── OrdinaryCounter.js
├── index.js
├── Counter.js
├── CycleCounter.js
├── FunNested.js
├── MixNested.js
├── App.js
└── CycleNested.js
├── .eslintrc
├── LICENSE
├── package.json
├── CHANGELOG.md
└── README.md
/examples/ReactNativeDemo/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | build/
3 | lib/
4 |
5 | *.swp
6 |
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015", "stage-0", "react"]
3 | }
4 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | build/
3 |
4 | *.swp
5 |
6 | .babelrc
7 |
--------------------------------------------------------------------------------
/examples/ReactNativeDemo/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["react-native"]
3 | }
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | module.exports = require('./lib/index')
4 |
--------------------------------------------------------------------------------
/examples/hello/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015", "stage-0", "react"]
3 | }
4 |
--------------------------------------------------------------------------------
/examples/http/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015", "stage-0", "react"]
3 | }
4 |
--------------------------------------------------------------------------------
/examples/time/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015", "stage-0", "react"]
3 | }
4 |
--------------------------------------------------------------------------------
/examples/simple-todos/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015", "stage-0", "react"]
3 | }
4 |
--------------------------------------------------------------------------------
/src/native.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | // TODO handle native View
4 | export * from './index'
5 |
--------------------------------------------------------------------------------
/native.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | // TODO remove this file later
4 | module.exports = require('./lib/native')
5 |
--------------------------------------------------------------------------------
/examples/ReactNativeDemo/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'ReactNativeDemo'
2 |
3 | include ':app'
4 |
--------------------------------------------------------------------------------
/examples/ReactNativeDemo/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
= { type: string, payload: P } 6 | export type TypedCtor
= (payload: P) => Typed
7 | export type TypedCtorMap = { [key: string]: TypedCtor
46 | (
47 | fnMap: MapFnMap ,
48 | otherwise?: MapFn , extra: B): C => {
51 |
52 | const fn = fnMap[obj.type]
53 | if (fn) {
54 | return fn(obj.payload, extra)
55 | }
56 |
57 | if (otherwise) {
58 | return otherwise(obj, extra)
59 | }
60 |
61 | throw new Error('obj type not handled with type: ' + obj.type)
62 |
63 | }
64 |
65 | export type Fn = (a: A) => B
66 |
67 | export const compose =
68 |
69 | (f: Fn, g: Fn): Fn => {
70 | const h = x => f(g(x))
71 | h.typeName = f.typeName
72 | return h
73 | }
74 |
--------------------------------------------------------------------------------
/examples/simple-todos/index.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | import React from 'react'
4 | import ReactDOM from 'react-dom'
5 | import {
6 | createTypes,
7 | caseOf,
8 | createView,
9 | createProgram,
10 | fromSimpleInit,
11 | fromSimpleUpdate,
12 | trace,
13 | } from '../../src'
14 |
15 | // 1. define your init model
16 | const init = {
17 | currentInputText: '', // input state
18 | seq: 0, // sequential id
19 | todos: [] // no todo item initially
20 | }
21 |
22 | // 2. define Msg, which is basically a wrapper of ui event
23 | // createTypes help us to annotate the data
24 | const Msg = createTypes(
25 | 'InputChange',
26 | 'Add', 'Delete',
27 | 'Check', 'ChangeVisibility'
28 | )
29 |
30 | // 3. define update function (the reducer)
31 | const update = caseOf({
32 | InputChange: (event: Object, model) => ({
33 | ...model,
34 | currentInputText: trace(event.target.value, event.target.value)
35 | }),
36 |
37 | Add: (_, model) => ({
38 | ...model,
39 | currentInputText: '',
40 | seq: model.seq + 1,
41 | todos: [...model.todos, {
42 | id: model.seq + 1, title: model.currentInputText
43 | }]
44 | })
45 | })
46 |
47 | // 4. define view
48 | const SimpleTodoList = createView('SimpleTodoList', ({model}, {event}) => (
49 | console.log('button 1', name)}
63 | onItemClick2={name => console.log('button 2', name)}
64 | />
65 | )
66 | })
67 |
--------------------------------------------------------------------------------
/src/program.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | import React from 'react'
4 | import {Observable, Subject} from 'rx'
5 | import {component} from './component'
6 | import type {ComponentOptions} from './component'
7 |
8 | import type {Typed, MapFn} from './type-system'
9 | import {DEV_MODE, config} from './config'
10 |
11 | // ----- main functions ------
12 | export type UpdateFn
Count: {model}
82 |
83 |
84 |