3 ms·
It's super dependant on the app. however, abstracting your api calls to a single library is helpful for any app beyond the most simple todo app. Things like th
by ehutch79 7y ago
It's super dependant on the app. however, abstracting your api calls to a single library is helpful for any app beyond the most simple todo app.
Things like the current user are 100% global state.
A list of user settings, or valid values for a dropdown that doesn't change often (like a list of timezones, or countries), totally global state.
A list of objects only shown on one page or in one component? That component can call an api library for the data itself.
State of a component? Definitely not global scope. Specific example; virtual scroll for a table. storing the offset as global scope. As soon as a second instance of the component was loaded on the same page there would be major issues.
Data that gets paginated should probably not be in global state, or cached heavily, depending on the app. A couple dozen entries is fine, but the idea of pulling every record in a list from say, an erp app, and then paginating in memory, would wreak havoc on a user's browser. And you're keeping that in the browsers session memory. Not to mention ramifications on the backend, even if it is cached. and then you need to deal with cache invalidation, and then...