Always cancel your XHR requests before firing a new one. It solves lots of bugs.
The native XHR object has an abort method. Use a library that either gives you access to the xhr object, or wraps it
with some other system for aborting.
Then,
| import {Resource, State} from 'simple-resource-components'; | |
| return ( | |
| <Resource names={['request', 'movie']}> | |
| <div className="movieTitle"> | |
| <State for="movie" type="loading" component={LoadingComponent}/> | |
| </div> | |
| <div className="requestDetail"> | |
| <State for={['request', 'movie']} type="loading" component={LoadingComponent}/> | |
| </div> |
| INSERT INTO the_table (id, column_1, column_2) | |
| VALUES (1, 'A', 'X'), (2, 'B', 'Y'), (3, 'C', 'Z') | |
| ON CONFLICT (id) DO UPDATE | |
| SET column_1 = excluded.column_1, | |
| column_2 = excluded.column_2; |
| { | |
| "person": { | |
| "name": "Please", | |
| "age": 24 | |
| } | |
| } |
| import { xhrStatuses } from 'redux-simple-resource'; | |
| function findResourceById({ state, resourceName, idAttribute = 'id', id }) { | |
| return state[resourceName].resources.filter(r => r[idAttribute] === id); | |
| } | |
| function checkReadManyStatus({ state, resources, status, every, includeNull }) { | |
| const check = every ? 'every' : 'some'; | |
| let arrayResources = resources instanceof Array ? resources : [resources]; | |
| return resources |
| export class App extends Component { | |
| render() { | |
| const { store } = this.props; | |
| return ( | |
| <Provider store={store} key="provider"> | |
| <Route for="dashboard" component={DashboardPage}/> | |
| <Route for="notFound" component={NotFoundPage}/> | |
| </Provider> | |
| ); |
| combineStatuses({ | |
| state, | |
| every: true, | |
| statuses: [ | |
| { | |
| action: 'read', | |
| resourceName: 'movies', | |
| id: 23 | |
| } | |
| ] |
asd
| asdasd |
| asdasd |