Skip to content

Instantly share code, notes, and snippets.

@milankinen
Created October 23, 2015 10:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milankinen/3f045eaf840afd12fefb to your computer and use it in GitHub Desktop.
Save milankinen/3f045eaf840afd12fefb to your computer and use it in GitHub Desktop.
Bottom-up-MÖLLYKKÄ
import React from "react"
import {combineAsArray} from "baconjs"
import Counter from "./components/counter"
import BigList from "./components/bigList"
export default initialState => (
combineAsArray(Counter(initialState), BigList()).map(
([$counter, $list]) => (
<div>
<h1>Tsers!</h1>
{$counter}
{$list}
</div>
)
)
)
import React from "react"
import Bacon from "baconjs"
import {range} from "lodash"
export default () => (
Bacon.constant(range(100000)).map(items => (
<ul>
{items.map(it => <li key={it}>item #{it}</li>)}
</ul>
))
)
import React from "react"
import {createAction} from "megablob"
const increment = createAction()
const decrement = createAction()
function stateP({counter = 0}) {
return increment.$
.map(1)
.merge(decrement.$.map(-1))
.scan(counter, (state, delta) => state + delta)
}
export default initialState => (
stateP(initialState).map(counter => (
<div>
Counter value is {counter} ..
<div>
<button onClick={increment}>+</button>
<button onClick={decrement}>-</button>
</div>
</div>
))
)
import React from "react"
import {render} from "react-dom"
import {startApp} from "megablob"
import {partialRight} from "lodash"
import App from "./application"
const renderApp = partialRight(render, document.getElementById("app"))
startApp(window.INITIAL_STATE, App, renderApp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment