Skip to content

Commit f8c395d

Browse files
skryukovbknoles
authored andcommitted
Deprecate InertiaRails.lazy prop
1 parent 6265817 commit f8c395d

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,12 @@ end
188188
}
189189
```
190190

191-
### Lazy Props
191+
### Optional Props
192192

193-
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.
193+
On the frontend, 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 initial load. In this case, you can use Optional props. Optional props aren't evaluated unless they're specifically requested by name in a partial reload.
194194

195195
```ruby
196-
inertia_share some_data: InertiaRails.lazy(lambda { some_very_slow_method })
197-
198-
# Using a Ruby block syntax
199-
inertia_share some_data: InertiaRails.lazy { some_very_slow_method }
196+
inertia_share some_data: InertiaRails.optional { some_very_slow_method }
200197
```
201198

202199
### Routing
@@ -269,6 +266,14 @@ end
269266

270267
__Default__: `false`
271268

269+
#### `encrypt_history`
270+
271+
When enabled, you instruct Inertia to encrypt your app's history, it uses
272+
the browser's built-in [`crypto` api](https://developer.mozilla.org/en-US/docs/Web/API/Crypto)
273+
to encrypt the current page's data before pushing it to the history state.
274+
275+
__Default__: `false`
276+
272277
#### `ssr_enabled` _(experimental)_
273278

274279
Whether to use a JavaScript server to pre-render your JavaScript pages,

lib/inertia_rails/lazy_prop.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ class LazyProp < IgnoreOnFirstLoadProp
55
def initialize(value = nil, &block)
66
raise ArgumentError, 'You must provide either a value or a block, not both' if value && block
77

8+
InertiaRails.deprecator.warn(
9+
"`lazy` is deprecated and will be removed in InertiaRails 4.0, use `optional` instead."
10+
)
11+
812
@value = value
913
@block = block
1014
end

spec/inertia/lazy_prop_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
RSpec.describe InertiaRails::LazyProp do
22
it_behaves_like 'base prop'
33

4+
let(:deprecator) do
5+
double(warn: nil).tap do |deprecator|
6+
allow(InertiaRails).to receive(:deprecator).and_return(deprecator)
7+
end
8+
end
9+
10+
it "is deprecated" do
11+
expect(deprecator).to receive(:warn).with("`lazy` is deprecated and will be removed in InertiaRails 4.0, use `optional` instead.")
12+
13+
described_class.new('value')
14+
end
15+
416
describe '#call' do
517
subject(:call) { prop.call(controller) }
618
let(:prop) { described_class.new('value') }

0 commit comments

Comments
 (0)