(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
function visibilityFilter(state = 'SHOW_ALL', action) { | |
switch (action.type) { | |
case 'SET_VISIBILITY_FILTER': | |
return action.filter; | |
default: | |
return state; | |
} | |
} | |
function todos(state = [], action) { |
import React, { PropTypes } from 'react'; | |
/** | |
* Define React Presentational Component Todos | |
*/ | |
const Todos = ({todos, onToggle }) => { | |
return ( | |
<ul> | |
{todos.map((todo) => ( | |
<li |
import React, { PropTypes } from 'react'; | |
/** | |
* Define React Presentational Component Header | |
*/ | |
const Header = ({visible, setVisible}) => { | |
const getStyle = (type) => { | |
if (visible === type) { | |
return { | |
textDecoration: 'underline' |
import React from 'react'; | |
import { bindActionCreators } from 'redux'; | |
import { connect } from 'react-redux'; | |
import * as ActionCreators from '../actions'; | |
import Add from '../components/add'; | |
import Todos from '../components/todos'; | |
import Header from '../components/header'; |
export default function combineReducers(reducers) { | |
var reducerKeys = Object.keys(reducers) | |
var finalReducers = {} | |
for (var i = 0; i < reducerKeys.length; i++) { | |
var key = reducerKeys[i] | |
if (typeof reducers[key] === 'function') { | |
finalReducers[key] = reducers[key] | |
} | |
} | |
var finalReducerKeys = Object.keys(finalReducers) |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
Blog Post
(by @hckrmoon)
class Rational(x: Int, y: Int) { | |
require(y != 0, "denominator must be nonzero"); | |
def this(x: Int) = this(x, 1) | |
private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b) | |
private val g = gcd(x, y) | |
def numer = x / g | |
def denom = y / g | |
class Rational(n: Int, d: Int) { | |
require(d != 0) | |
private val g = gcd(n.abs, d.abs) | |
val number = n /g | |
val denom = d / g | |
def this (n: Int) = this(n, 1) | |
def + (that: Rational): Rational = |
if (true) { | |
var a = 'hacker'; | |
let b = 'moon'; | |
console.log('a => ', a); // hacker | |
console.log('b => ', b); // moon | |
} | |
console.log('a => ', a); // hacker | |
console.log('b => ', b); // b is not defined |