This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import { render } from 'react-dom' | |
import { createStore, bindActionCreators } from 'redux' | |
import { connect, Provider } from 'react-redux' | |
const increment = () => ({ type: 'increment' }) | |
const counter = (state = 0, action) => { | |
switch (action.type) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { MongoClient } from 'mongodb'; | |
import assert from 'assert'; | |
const url = 'mongodb://localhost:27017/test'; | |
MongoClient.connect(url, (err, db) => { | |
assert.equal(null, err); | |
console.log('connected'); | |
db.close(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { render } from 'react-dom'; | |
import { Map, List } from 'immutable'; | |
class App extends Component { | |
constructor () { | |
super(); | |
this.state = { data: Map({ | |
name: 'init', | |
pass: 'init' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import request from 'superagent'; | |
import thunk from 'redux-thunk'; | |
import createLogger from 'redux-logger'; | |
import { createStore, applyMiddleware } from 'redux'; | |
const req = () => ({ type: 'REQ' }); | |
const rec = data => ({ type: 'REC', data }); | |
const fetch = () => dispatch => { | |
dispatch(req()); | |
return request.get('http://localhost:3000/api') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import { render } from 'react-dom' | |
import { createStore, combineReducers, applyMiddleware, compose, bindActionCreators } from 'redux' | |
import { Provider, connect } from 'react-redux' | |
import { Router, Route, IndexRoute, Link } from 'react-router' | |
import { reduxReactRouter, routerStateReducer, ReduxRouter } from 'redux-router' | |
import { createHistory } from 'history' | |
import { devTools, persistState } from 'redux-devtools' | |
import { DevTools, DebugPanel, LogMonitor } from 'redux-devtools/lib/react' | |
import createLogger from 'redux-logger' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const n3 = { val: 3, nxt: null } | |
const n2 = { val: 2, nxt: n3 } | |
const n1 = { val: 1, nxt: n2 } | |
const fst = n => n.val | |
const rst = n => n.nxt | |
const cons = (val, n) => { val, nxt: n } | |
fst(n1) // 1 | |
fst(rst(n1)) // 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class App extends Component { | |
render = () => { | |
const { pathname } = this.props.location | |
const root = pathname === '/' | |
return ( | |
<div> | |
<li><Link to="/one">One</Link></li> | |
<li><Link to="/two">Two</Link></li> | |
<ReactCSSTransitionGroup component="div" transitionName={ root ? forward : reverse } > | |
{ React.cloneElement(this.props.children || <div />, { key: pathname }) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ createClass } = React | |
{ render } = ReactDOM | |
Tasks = new Mongo.Collection('tasks') | |
if Meteor.isClient | |
Accounts.ui.config(passwordSignupFields: "USERNAME_ONLY") | |
Meteor.subscribe('tasks') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default store => next => action => { | |
if (!action.request) | |
return next(action) | |
const { types, request, ...rest } = action | |
const [ REQUEST, SUCCESS, FAILURE ] = types | |
next({ ...rest, type: REQUEST }) | |
fetch(request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { render } from 'react-dom'; | |
import { createStore, applyMiddleware, bindActionCreators, combineReducers } from 'redux'; | |
import thunk from 'redux-thunk'; | |
import { Provider, connect } from 'react-redux'; | |
import { Map } from 'immutable' | |
import createLogger from 'redux-logger' | |
const logger = createLogger() | |
// Actions |
OlderNewer