guides-source
guides-source copied to clipboard
WIP - Create a dedicated section on application data flow/requests
This topic is still under discussion and isn't ready yet to be picked up by contributors. The goal is to first work out some of the big questions of what this section should look like, acceptance criteria, MVP, etc.
The proposal is to create a new topic under Core Concepts where we tackle questions like "where should I load data," loading data in components, etc. It is motivated by the popularity of this Readers' Question, and that we ought to have something octaney here: https://discuss.emberjs.com/t/readers-questions-is-it-bad-to-load-data-in-components/14521
to start off the discussion here are some thoughts on this matter:
- when is it appropriate to use/avoid
- how does one handle loading and error sub-states
- how does it look like for ember-data
- should a user make 'fetch' requests inside the component itself/ or use a purpose built service
- testing data loading components, controlling timing, stubbing implementation so all functionality can be tested
- dropping/restarting/cancelling active data loading requests (in case component gets destroyed/ user interaction triggers)
- ephemeral nature of data in components (what does the back button do) - balancing the number of requests that get made when a component is reused many times and more importantly rendered many times; and how choices about using a service or containing the data in the component ends up impacting the state of the (maybe same) data displayed on screen;
- using websockets in a component
Some lingering questions:
- what does it mean for fastboot
- is it worth deferring until use and resources progresses; would that make this question trivial to answer
- what does that mean for DDAU and the ownership of the data
there is much to discuss here and I'm sure I've overlooked something important but hopefully the above is a starting point
Draft outline
Top-level table of contents topic: Making API requests? URL: data?
Topics:
- Intro - why are we here. Very quick fetch in a route as an example, brief how to decide to where to put the code (component, route, service), where Ember Data fits in and should I use it, what are alternatives (native fetch, GraphQL, Apollo, Orbit), some advice for beginners, link to testing
- Route - example w/fetch & Ember data, why, lifecycle, loading template, testing link. Make sure it's complementary of other route guides
- Component - example w/fetch & Ember data, why, lifecycle, loading state (submit button w/spinner). Mention async helpers like ember-concurrency, ember-await, and ember-lifeline and the problems you face without them. Testing link
- Service - example w/fetch & Ember data, why, lifecycle. Show notifications/websockets type example (not MVP), storing data example, how to use the service in the route/component. Make sure it's complementary with https://guides.emberjs.com/release/services/ Testing link
- Error handling - onerror example, error template
MVP
- Intro, Route, Component
Complexity
- Will have some overlap with Ember data, by necessity
- How to talk about ember-concurrency? Need to talk w/core teams.
Misc To-dos
- [ ] Locate or write data handling content in the existing Testing guides, so we can link to it. Mention Mirage, pretender. Could add a distinct topic or sprinkle it throughout.
- [ ] Ember data's urls say models. Weird! Change this to ember-data?
- [ ] Make Ember data guides be more like Ember Data Guides - needs a review to deduplicate