Tubo Frames decompose your page in parts using tag <turbo-frame>, which can be replaced by copies received by the server, just locating and replacing them thanks to identifiers. For example we can manage a message in your list of messages annotating with this tag "_message.html.erb":
<%= turbo_frame_tag @message do %>
......
<%= link_to @messages, data: { turbo_frame: "_top" } %>
......
<% end %>
In this ERB code frame would be replaced inside the tags, but the link to all messages will be replaced in full body of HTML page. Here is the translation to HTML code:
<turbo-frame id="message_1">
......
<a href="/messages" data-turbo-frame="_top" />
......
</turbo-frame>
In controller we send only "_message.html.erb" rendered
def show
@message = Message.find(params[:id])
render @message
end
Eager-loaded frame: Replaced when "/messages" are loaded. Adding "src: @messages" to your ERB file.
Lazy-loaded frame: Content will be replaced when frame is visible. Add [loading: "lazy"]to ERB tag
Frame targets: manage where to be replaced
Advance/replace on browser history: By default takes replace strategy, but you can create copies: <turbo-frame data-turbo-action="advance">
Anti-forgery support (CSFF):
Several Frame attributes and JavaScript properties:
Check reference, they are very useful on development.
Is the most important part of Turbo, despite it seems the simplest, I think it's because frames and streams seems more spectacular. It basically avoids full-reloading of HTML page, just replacing the <body>, giving a clean sense of navigation. Intercepting usual HTTP requests and use fetch for server calls. It also manages full browser history with advance/replace/restore actions.
We can decompose its main features in 15 points:
Turbo is the evolution of turbolinks Rails library, done to make your web app navigation faster. Giving the performance of a single-page application (like Reac) but with much less complexity and much cheaper development costs in money and time.
We can decompose Turbo in several parts:
Enjoy the invent!