You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+63Lines changed: 63 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,6 +101,67 @@ class EventsController < ApplicationController
101
101
end
102
102
```
103
103
104
+
#### Deep Merging Shared Data
105
+
106
+
By default, Inertia will shallow merge data defined in an action with the shared data. You might want a deep merge. Imagine using shared data to represent defaults you'll override sometimes.
107
+
108
+
```ruby
109
+
classApplicationController
110
+
inertia_share do
111
+
{ basketball_data: { points:50, rebounds:100 } }
112
+
end
113
+
end
114
+
```
115
+
116
+
Let's say we want a particular action to change only part of that data structure. The renderer accepts a `deep_merge` option:
# Even if deep merging is set by default, since the renderer has `deep_merge: false`, it will send a shallow merge to the frontend:
158
+
{
159
+
basketball_data: {
160
+
points:100,
161
+
}
162
+
}
163
+
```
164
+
104
165
### Lazy Props
105
166
106
167
On the front end, Inertia supports the concept of "partial reloads" where only the props requested are returned by the server. Sometimes, you may want to use this flow to avoid processing a particularly slow prop on the intial load. In this case, you can use Lazy props. Lazy props aren't evaluated unless they're specifically requested by name in a partial reload.
@@ -139,6 +200,8 @@ InertiaRails.configure do |config|
0 commit comments