コード例 #1
0
ファイル: main.js プロジェクト: Softsapiens/elmish
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
  }
})
コード例 #2
0
  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) )
      )
    );
  });
コード例 #3
0
ファイル: request.js プロジェクト: maxidr/gromit
module.exports = (method, path, more) => m.request(
  merge({ 
    method: method, url: serverUrl() + path,
    unwrapError: pipe(unwrapError, trace('Request error: '), redirectOnForbidden), 
    config: addAuthorization 
  }, more || {})
)
コード例 #4
0
ファイル: followingList.js プロジェクト: Softsapiens/elmish
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
  }
})
コード例 #5
0
ファイル: tabvc.js プロジェクト: Softsapiens/elmish
 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
   }
 })
コード例 #6
0
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)             ])
    ])
  );

});
コード例 #7
0
ファイル: tabvc.js プロジェクト: Softsapiens/elmish
  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),
    })
  })
コード例 #8
0
  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>
    );
  }
コード例 #9
0
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] : [])
     ])       
  );

}
コード例 #10
0
ファイル: PreCompareEvent.js プロジェクト: yjxf8285/test
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,
);
コード例 #11
0
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();
コード例 #12
0
const renderAbort = (model) => (
  h('a', { style: merge(visible(abortable, model), {cursor: 'pointer'}),
           on: { click: model.abort } }, 
    actionLabel('abort')
  )
)
コード例 #13
0
ファイル: 02-text-fields.js プロジェクト: flintinatux/lemur
 Change: (content, model) => merge(model, { content })
コード例 #14
0
ファイル: FormStore.js プロジェクト: stoolio/MyLilCrm
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;