-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data fetch #1
Comments
Thanks, appreciate it! I have a data fetching example that should be up within a day or two. |
Sweet. Like your plate because of the simplicity. Look forward to checking the fetch examples out. |
Great! Yeah I made this because I wanted a simple, barebones boilerplate that could still do the basic stuff needed without it getting needlessly complicated and I plan to keep things that way :) |
Would this be how you do it / where you put the fetching? ` constructor() {
} } ` |
And in the component:
...
|
That looks good to me, pretty much how I would go about it. |
If you want to use async/await I'd recommend this pattern for actions.
|
Thx for the reply and I hope you recover swiftly. I went ahead and put the fetching in the store itself and invoking the initial call from componentDidMount that calls an actionfunction in the component that calls the fetch function in the store that updates the store data, Makes sense to me have all the API-fetching all in one place in the store. Straight forward and simple to follow the flow and not over architected. |
Thanks! Feeling better already. |
It's a very elegant solution for handling the endpoints. Had to get my head around the wrapper component you made, but very cool. Most endpoints only return x number of posts per page at which point you get into either using a query filter for ALL or using some pagination. Since this boilerplate clears items every time, pagination seems trivial to add, but each time a person traverses forward and backward, the data fetch happens again and introduces lag time. I have been thinking about this problem and how to keep the solution simple, while reducing lag and fetching. In another project, I just fetched all posts into the store, and then queried the store with the router params instead of the endpoint, which meant instant loading and seemless forward/backward... But, that only works with a small data set and creates other problems with going directly to a single post url.... I wonder how you handle these issues in your projects. Thanks for the great boilerplate, BTW!!! |
Nice work. Where would you put the API calls going to the backend. In the store, the component or elsewhere?
The text was updated successfully, but these errors were encountered: