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 React from 'react'; | |
| class Welcome extends React.Component { | |
| render() { | |
| return <div> Welcome {this.props.name} </div> | |
| } | |
| } | |
| export default Welcome; |
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
| const addTodo = (description, date) => ({ | |
| type: 'ADD_TODO', | |
| payload: { | |
| description: description, | |
| date: date, | |
| }, | |
| }); |
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
| const todoAction = addTodo('Write post about ARC', '2017-07-08') | |
| /* | |
| * { | |
| * type: 'ADD_TODO', | |
| * description: 'Write post about ARC', | |
| * date: '2017-07-08' | |
| * } | |
| */ |
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
| const middleware = store => next => action => { | |
| next(action); | |
| }; |
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
| { | |
| type: ['ADD_TODO_REQUEST', 'ADD_TODO_RESPONSE'], | |
| payload: { | |
| description: 'Write post about ARC', | |
| date: '2017-07-08', | |
| }, | |
| meta: { | |
| url: 'path/to/add-to-do', | |
| method: 'post' | |
| }, |
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 axios from 'axios'; | |
| export function createAsyncMiddleware() { | |
| return store => next => (action) => { | |
| const { type, meta } = action; | |
| if (!Array.isArray(type)) { | |
| return next(action); | |
| } |
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
| const TODO_ADD_REQUEST = 'TODO_ADD_REQUEST'; | |
| const TODO_ADD_RESPONSE = 'TODO_ADD_RESPONSE'; | |
| const TODO_LIST_REQUEST = 'TODO_LIST_REQUEST'; | |
| const TODO_LIST_RESPONSE = 'TODO_LIST_RESPONSE'; | |
| const TODO_READ_REQUEST = 'TODO_READ_REQUEST'; | |
| const TODO_READ_RESPONSE = 'TODO_READ_RESPONSE'; | |
| const TODO_UPDATE_REQUEST = 'TODO_UPDATE_REQUEST'; |
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
| const TODO_ADD_REQUEST = 'TODO_ADD_REQUEST'; | |
| const TODO_ADD_RESPONSE = 'TODO_ADD_RESPONSE'; | |
| const add = (description, date) => ({ | |
| type: [TODO_ADD_REQUEST, TODO_ADD_RESPONSE], | |
| payload: { | |
| description, | |
| date, | |
| }, | |
| meta: { |
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 { createApiActions } from 'redux-arc'; | |
| const { creators, types } = createApiActions('todo', { | |
| add: { url: 'path/to/to-do', method: 'post' } | |
| }); |
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
| const payload = { | |
| description: 'Create post about ARC', | |
| date: '2017-08-01', | |
| }; | |
| dispatch(creators.add({ payload: payload })) |