Querying for data #29
joeldrapper
started this conversation in
Ideas
Replies: 2 comments 1 reply
-
Is my understanding of StaticComponents correct, such that if a Component is a StaticComponent, it cannot contain queries and cannot mutate data? |
Beta Was this translation helpful? Give feedback.
1 reply
-
I think the new |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I think we have an opportunity to design a pattern that significantly improves safety and performance when querying for data to render into views. Here's a profile of a typical Rails view:
Rails starts rendering the views but has to stop several times to query the database. Some of these queries haven't even been issued to the database until about half way through the response.
Ideally, each of these database queries would have been issued as early as possible — either as the first thing that happened when the controller action was hit or immediately after a contingent query had finished.
I think we can achieve this by wrapping queries in Ractors which are then consumed by subsequent queries and/or components. The components can call
take
on the query ractors when they need the data. We should also render components in Ractors so they don't themselves need to wait on sibling components.Additionally, data should be immutable from within a view. Views can render forms, but they should never directly mutate data.
Beta Was this translation helpful? Give feedback.
All reactions