View useSubscription.diff
@@ -23,8 +23,8 @@ export function useSubscription({ getCurrentValue, subscribe }) { | |
useEffect(() => { | |
let didUnsubscribe = false; | |
- | |
- const checkForUpdates = () => { | |
+ // NOTICE: value coming from subscription not from getCurrentValue !!! | |
+ const onValue = value => { | |
if (didUnsubscribe) { | |
return; |
View example.ts
import * as L from "partial.lenses"; | |
interface State { | |
foo: { | |
lol: number; | |
bal: string; | |
}; | |
items: Item[]; | |
} |
View index.js
const vm = require("vm"); | |
const { resolve, run } = require("./sync"); | |
// in "master" | |
const calls = []; | |
const log = console.log.bind(console); | |
const random = Math.random; | |
// in "worker" |
View app.js
import {Observable as O} from 'rx' | |
import L from "partial.lenses" | |
import R from "ramda" | |
import {h3, div} from '@cycle/dom' | |
import isolate from '@cycle/isolate' | |
import Ticker from './ticker' | |
import {liftListById, flatCombine, flatMerge} from "stanga" | |
function intent(tickers$) { |
View index.js
import * as O from "most" | |
import * as L from "partial.lenses" | |
import DOM from "@culli/dom" | |
import Store, {Memory, byType} from "@culli/store" | |
import {run} from "@cycle/most-run" | |
// partial.lenses lens => culli lens | |
const P = (pl) => ({ | |
get: L.get(pl), | |
set: L.set(pl) |
View flatUpdate.js
const Bacon = require("baconjs") | |
/** | |
* flatUpdate :: (state, [Observable+, [(state,...events)=>Observable<A>, (state, A)=>newState]]+) => Observable<state> | |
* | |
* const stateP = flatUpdate(initialState, | |
* [event1S], (state, newState) => newState, // supports normal Bacon.update | |
* [event2S], (state, newState) => Bacon.later(100, newState) // supports delayed state updating | |
* [event3S], [submitForm, handleSubmitResult] // supports 2-stage state updating | |
* ) |
View devtools.js
import {O, extend} from "@culli/base" // you can replace this with your own streaming library if you want | |
import Memory from "./memory" | |
function ReduxDevtools(initial) { | |
const devtools = window.__REDUX_DEVTOOLS_EXTENSION__ | |
if (!devtools) { | |
return Memory(initial) | |
} |
View main.js
import * as O from "most" | |
import {run} from "@cycle/most-run" | |
import DOM from "@culli/dom" | |
import Store, {Memory} from "@culli/store" | |
import HTTP from "@culli/http" | |
run(GithubSearch, { | |
DOM: DOM("#app"), | |
// create store using in-memory persintence |
View main.js
import {Observable as O} from "rx" | |
const store = reducer => R.lens(R.identity, reducer) | |
const myStore = store((action, state) => { | |
switch (action.type) { | |
case "INC": return state + 1 | |
case "DEC": return state - 1 | |
default: return state | |
} |
View monkey.js
Rx.Observable.prototype.log = function(prefix) { | |
return process.env.NODE_ENV !== "development" ? this : this | |
.doOnCompleted(() => console.log(prefix, "<completed>")) // eslint-disable-line | |
.do(x => console.log(prefix, x)) // eslint-disable-line | |
} | |
// const obs = Rx.Observable.fromEvent(text, "input") | |
// .log("InputEvent:") | |
// .map(e => e.target.value) | |
// .filter(t => !!t) |
NewerOlder