const update = curry((state, action) => { switch (action.type) { case 'newGif': // the http success response return merge(state, { url: action.url, pending: false }) case 'errorGif': // the http error response console.warn("ERROR:", state, action) return merge(state, { url: errorGif, pending: false }) case 'anotherGif': // request a new gif return merge(state, { url: loadingGif, key: randomId(), pending: true }) default: return state } })
const view = curry( ({style=initStyle(), action$}, model) => { style.ul = merge(style.ul || {}, fixedStyle.ul); style.li = merge(style.li || {}, fixedStyle.li); return ( h('ul', {style: style.ul}, model.items.map( itemView(action$, style.li, model) ) ) ); });
module.exports = (method, path, more) => m.request( merge({ method: method, url: serverUrl() + path, unwrapError: pipe(unwrapError, trace('Request error: '), redirectOnForbidden), config: addAuthorization }, more || {}) )
const update = curry((state, action) => { switch (action.type) { case 'following': return merge(state, { following: action.following, pending: false, error: false }) case 'error': console.warn("ERROR:", state, action) return merge(state, { following: [], pending: false, error: action.error }) default: return state } })
const update = curry((state, action) => { switch (action.type) { case 'change': return merge(state, { index: action.index }) case 'child': // XXX I really wish there was a cleaner way of doing this every time. const updateChildState = children[action.index].update(__, action.action) const updateChildStates = adjust(updateChildState, action.index) return evolve({states: updateChildStates}, state) default: return state } })
const view = curry( ({progress},model) => { progress = merge({width: 200, height: 20}, progress || {}); return ( h('div', { attrs: { 'class': 'upload ' + model.status }, style: style.upload }, [ h('div.title', {style: style.div}, [ renderTitle(model) ]), h('div.size', {style: style.div}, [ ''+size(model) ]), h('div.progress', {style: style.div}, [ renderProgress(model,progress) ]), h('div.status', {style: style.div}, [ renderStatus(model) ]), h('div.abort', {style: dissoc('margin-right', style.div)}, [ renderAbort(model) ]) ]) ); });
const declare = curry((dispatch, state) => { // change the tab index const change = (index) => dispatch({'type': 'change', index}) const dispatchChild = (index) => (action) => dispatch({type:'child', index, action}) const declareChild = (c, i) => c.declare(dispatchChild(i), state.states[i], {index: state.index, change}) const effects = mapIndexed(declareChild, children) const html = map(prop('html'), effects) const fx = pipe( map(omit(['html'])), concatAllEffects )(effects) return merge(fx, { html: h('div.tabvc', {style}, html), }) })
render() { let {children} = this.props; const {store, memoryProps} = this.props; const state = merge(initialState, store || {}); children = ( <Provider store={configureStore(state)}> {children} </Provider> ); return ( <ThemeProvider theme={myTheme}> <IntlProvider locale="en" messages={localeData}> <MemoryRouter {...memoryProps}> {children} </MemoryRouter> </IntlProvider> </ThemeProvider> ); }
const renderProgress = (model,specs) => { const barwidth = percentProgress(model.progress) * specs.width; const linespecs = { x1: specs.width, x2: specs.width, y1: 0, y2: specs.height }; const rect = ( s('rect', { attrs: { height: specs.height, width: barwidth, class: 'bar' } }) ); const line = ( s('line', { attrs: merge(linespecs, {class: 'end'}) } ) ); return ( s('svg', {attrs: specs}, [ s('g', {}, (barwidth > 0) ? [rect,line] : []) ]) ); }
import compose from 'ramda/src/compose'; import merge from 'ramda/src/merge'; const defaults = merge({ bubbles: true, cancelable: true, eventPhase: 2, }); const createEvent = (options = {}) => new Event('precompare', options); export default compose( createEvent, defaults, );
const webpackRunner = require('../../../test/webpackRunner'); const serverWebpackConfig = require('../../webpack.config'); const testWebpackConfig = require('./webpack.config'); const childProcess = require('child_process'); const Promise = require('bluebird'); const runHelpers = require('../../../test/run-helpers'); const forkHelpers = require('../../../test/fork-helpers'); const merge = require('ramda/src/merge'); const forkOptions = { env: merge({ PORT: 3001, NODE_ENV: 'test', DISABLE_LOGGING: true }, process.env) }; function forkJasmine() { return forkHelpers.forkJasmine('server/test/endpoint', '.tmp', 'test.js', __dirname + '/../../../test-output', 'endpoint.xml', forkOptions); } const removeTempDirectory = function () { runHelpers.removeTempDirectory(__dirname + '/.tmp') }; let appProcesses; const appWatcher = webpackRunner.watch(serverWebpackConfig, function () { if (!appProcesses) { appProcesses = startForkedAppAndWatchTests();
const renderAbort = (model) => ( h('a', { style: merge(visible(abortable, model), {cursor: 'pointer'}), on: { click: model.abort } }, actionLabel('abort') ) )
Change: (content, model) => merge(model, { content })
import FormActions from '../actions/FormActions'; const FormStore = Reflux.createStore({ listenables: [FormActions], getInitialState() { this.state = {}; return this.state; }, onChange(group, field, val) { this.state || (this.state = {}); this.state[group] || (this.state[group] = {}); this.state[group][field] = val; this.trigger(this.state); }, onSetGroup(group, vals) { this.state[group] = vals; this.trigger(this.state); }, onSubmit(group, fn, extra = {}) { let formData = merge(this.state[group], extra); fn(formData); for (var field in this.state[group]) { this.state[group][field] = ''; } this.trigger(this.state); } }); export default FormStore;