This file contains hidden or 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 { Meteor } from 'meteor/meteor'; | |
import { createContainer } from 'meteor/react-meteor-data'; | |
import { connect } from 'react-redux'; | |
import React from 'react'; | |
import reactMixin from 'react-mixin'; | |
import Todos from '../../collection'; | |
import changePage from '../../../imports/client/actions/changePage'; | |
import toggleTodo from '../../../imports/client/actions/toggleTodo'; | |
import Todo from '../../../imports/client/components/Todo'; | |
import TodoPagination from '../../../imports/client/components/TodoPagination'; |
This file contains hidden or 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 Link from '../import/client/components/Link'; | |
import setVisibilityFilter from '../import/client/actions/setVisibilityFilter'; | |
export default FilterLink({ dispatch, filter, visibilityFilter, children }) { | |
return ( | |
<Link active={visibilityFilter === filter} onClick={()=> {return dispatch(setVisibilityFilter(filter))}}> | |
{children} | |
</Link> | |
); | |
}; |
This file contains hidden or 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 function Link({active,children,onClick}){ | |
if (active) { | |
return <span>{children}</span>; | |
} | |
return ( | |
<a href='#' | |
onClick={function (e){ | |
e.preventDefault(); | |
onClick(); | |
}} |
This file contains hidden or 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 function todoApp(state = initialState, action) { | |
switch (action.type) { | |
case "SET_VISIBILITY_FILTER": | |
// RETURNING A NEW STATE WHAT WHAT!!! | |
return Object.assign({}, state, { | |
visibilityFilter: action.filter | |
}) | |
default: | |
return state | |
} |
This file contains hidden or 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
{ | |
"react-mixin": "3.0.3", // So we can use Mixins with ES6 Classes | |
"redux": "3.0.5", // The library this blog post is about | |
"react-redux": "4.0.6" // redux bindings for react | |
"redux-thunk": "1.0.3", // How we can dispatch actions as funcs | |
"redux-logger": "2.3.1", // Logging state changes | |
"classnames": "2.2.1", // DOPE conditional css tool | |
"externalify": "0.1.0" // specify a custom name for require | |
"react-paginate": "0.5.0" | |
} |
This file contains hidden or 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
Redux = require('redux'); | |
thunkMiddleware = require('redux-thunk'); | |
createLogger = require('redux-logger'); | |
classNames = require('classnames'); | |
reactMixin = require('react-mixin'); | |
ReactRedux = require('react-redux'); | |
ReactPaginate = require('react-paginate'); |
This file contains hidden or 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
{ | |
"transforms": { | |
"externalify": { | |
"global": true, | |
"external": { | |
"react": "Package.react-runtime.React.require" | |
} | |
} | |
} | |
} |
This file contains hidden or 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
// in imports/collections.js | |
const Todos = new Mongo.Collection('todos'); | |
export default Todos; |
This file contains hidden or 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
// in server/publications.js | |
import Todos from '../imports/collection'; | |
Meteor.publish('getTodos', function (filter, pageSkip = 0) { | |
switch (filter) { | |
case 'SHOW_ALL': | |
return Todos.find({}, {skip: pageSkip, limit 10}); | |
case 'SHOW_COMPLETED': | |
return Todos.find({completed: true}, {skip: pageSkip, limit: 10}); | |
case 'SHOW_ACTIVE': |