Skip to content

Commit 2c229e8

Browse files
update async rerender_on description
1 parent ec1eb88 commit 2c229e8

File tree

1 file changed

+3
-27
lines changed

1 file changed

+3
-27
lines changed

docs/components/async.md

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,11 @@ async rerender_on: 'my_event' do
2222
end
2323
```
2424

25-
**Attention:** The `rerender_on` option lets you rerender parts of your UI asynchronously, which is cool. It does come with an implications that could lead to unintended behaviour, though. Take a look at the code below:
25+
**Note:** The `rerender_on` option lets you rerender parts of your UI asynchronously, which is cool. But please consider that, if not configured differently, it a) is **not** _lazily loaded_ and b) does get displayed on initial pageload.
2626

27-
```ruby
28-
class Pages::ExamplePage < Page::Cell::Page
29-
30-
def prepare
31-
user = User.last
32-
end
33-
34-
# ...
35-
36-
def response
37-
components {
38-
async rerender_on: 'my_event' do
39-
div id: 'my-div' do
40-
plain user.name
41-
end
42-
end
43-
}
44-
end
45-
46-
end
47-
```
48-
49-
Firstly, the async component gets displayed on initial pageload, showing the most recently added user's name. On every occurance of `my_event`, the `prepare` method gets called, again fetching the most recently added user from the DB. This could lead to 1) unwanted information on the UI adn 2) a lot of unnecessary DB queries. We recommend to keep a close eye on the async component and, for this example, calling a partial with the DB query within the `div id: 'my-div'`.
50-
51-
If you want _lazy loading_, e.g. not fetching the latest user from the DB on pageload but fetching them asynchronously later on, the async core component is currently being enhanced with a `defer: true` configuration, visible [here](https://github.com/basemate/matestack-ui-core/issues/58).
27+
Lazy (or defered) loading is a feature we're working on right now, for details see [here](https://github.com/basemate/matestack-ui-core/issues/58).
5228

53-
If you want to load the user name on pageload, initially hide it and display it later on, read below as this option (`show_on`) is already implemented!
29+
If you want to hide the async component on initial pageload and display it later on, read below as this option (`show_on`) is already implemented (and can be combined with `rerender_on`)!
5430

5531
### Show_on
5632

0 commit comments

Comments
 (0)