-
Notifications
You must be signed in to change notification settings - Fork 1
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
Investigate the alternatives #48
Comments
Parallel queries Parallel mechanism for fetching queries that use Solution with One option would be to create a hook
Solution with |
Static query Query that do not depend on the parameters (a resource) must be cached once. Also, there must be a possibility to invalidate cache sometimes (each N seconds or in case of localStorage, on page refresh, etc...) |
Single query Use case when a component has single query. Just throw a promise immediately. |
Dynamic query The type of query that depends on dynamic arguments. For example, query that depends on:
Maybe it would be a better option to create another hook for fetching infinite lists. But search query does not return consequential fragments of infinite list, but it still has ~ infinite number of possible keys. |
Dependent queries These types of queries depend on other queries' results. This can be done using |
Use of Now hook It is possible to treat remote data like local data in a component with Proxy functionality. When accessing some of the data field, proxy However, using |
The current approach using keys to cache queries The current approach is very simple: each query result is cached by stringified arguments of fetcher function. However, with this architecture it is very difficult to invalidate cache only for specific queries that depend on the mutated query. Consider the following scenario: EXAMPLE 1
User sends new message in chat. So, all queries that depend on this data must be invalidated / mutated. The question is, how can we do that? If we identify each query only by keys, then it is hard to manage all relations between queries. For example, we have a query for fetching messages (mark it A), which is being mutated. So, we need to invalidate all queries that depend on messages. Here is the list of dependent queries:
So, with current approach we need to manually follow the logic of invalidating caches (imperatively calling Complex application code is growing in complexity very fast. Imagine that when we change the EXAMPLE 2 The idea is that Also user could create new issue (trigger a mutation) that should cause update on issue list automatically. If we provide in |
Model-oriented caching The idea is that we have defined dependencies between queries in such a way that query A depends on query B when mutation on query B should cause update on query A. When user triggers a mutation (when data in DB changes) on particular query, then all queries that depend on it must be invalidated (TODO: decide if library should rerender dependent queries or not). Imagine the following example: Also the component Possible API |
This library currently lacks a lot of functionality. So we need to investigate the alternatives and define core functionality points of
only-suspense
based data fetching library.Useful links:
The text was updated successfully, but these errors were encountered: