Upgrade to Pro — share decks privately, control downloads, hide ads and more …

HOTWIRE - A new (old) approach for modern web a...

HOTWIRE - A new (old) approach for modern web applications

Felix Riess

October 21, 2022
Tweet

More Decks by Felix Riess

Other Decks in Technology

Transcript

  1. WEB APPLICATIONS APPLICATION STATE BUSINESS LOGIC ROUTING PRESENTATION LOGIC &

    TEMPLATING APPEARANCE & BEHAVIOR https://www.innoq.com/en/articles/2020/01/javascript-in-ma%C3%9Fen/
  2. „TRADITIONAL“ WEB APPLICATIONS APPLICATION STATE BUSINESS LOGIC ROUTING PRESENTATION LOGIC

    & TEMPLATING APPEARANCE & BEHAVIOR https://www.innoq.com/en/articles/2020/01/javascript-in-ma%C3%9Fen/
  3. „MODERN“ WEB APPLICATIONS APPLICATION STATE BUSINESS LOGIC ROUTING PRESENTATION LOGIC

    & TEMPLATING APPEARANCE & BEHAVIOR https://www.innoq.com/en/articles/2020/01/javascript-in-ma%C3%9Fen/
  4. „MODERN“ WEB APPLICATIONS WITH OFFLINE CAPABILITIES APPLICATION STATE BUSINESS LOGIC

    ROUTING PRESENTATION LOGIC & TEMPLATING APPEARANCE & BEHAVIOR https://www.innoq.com/en/articles/2020/01/javascript-in-ma%C3%9Fen/
  5. WE BUILT AN SPA TO AVOID FULL PAGE RELOADS INCLUDING

    REPARSING CSS AND JAVASCRIPT WE BUILT AN SPA FOR A BETTER USER EXPERIENCE WITH SMOOTH TRANSITIONS DURING NAVIGATION OUR DEVELOPERS HAVE BUILT ONLY SINGLE PAGE APPLICATIONS SO FAR
  6. https://hotwired.dev/ „HOTWIRE IS AN ALTERNATIVE APPROACH TO BUILDING MODERN WEB

    APPLICATIONS WITHOUT USING MUCH JAVASCRIPT BY SENDING HTML INSTEAD OF JSON OVER THE WIRE.“
  7. WE DON’T WANT FULL PAGE RELOADS! WE WANT SMOOTH TRANSITIONS

    DURING NAVIGATION! OUR DEVELOPERS DON’T WANT TO BUILD OLD SCHOOL JSF APPS. THEY WANT COOL TECHNOLOGIES!
  8. <turbo-frame id="todolist"> <table> <thead> <tr> <th>Title</th> <th>Completed</th> <th>Mark as done</th>

    </tr> </thead> <tbody> <tr> <td><a href="/todos/123">Todo</a></td> <td>Open</td> <td> <form action="/todos/123" method="POST" enctype="multipart/form-data"> <input type="submit" value="Done"> </form> </td> </tr> </tbody> </table> </turbo-frame>
  9. <turbo-frame id="todolist"> <table> <thead> <tr> <th>Title</th> <th>Completed</th> <th>Mark as done</th>

    </tr> </thead> <tbody> <tr> <td><a href="/todos/123">Todo</a></td> <td>Done</td> <td> <form action="/todos/123" method="POST" enctype="multipart/form-data"> <input type="submit" value="Done" disabled> </form> </td> </tr> </tbody> </table> </turbo-frame>
  10. UPDATING FRAMES FROM OUTSIDE <h1>TODO List</h1> <turbo-frame id="todolist" src="/todos"> <div

    class="loader"></div> </turbo-frame> <h1>Create TODO</h1> <form action="/todos" method="POST" enctype="multipart/form-data" data-turbo-frame="todolist"> <label for="name">TODO:</label> <input type="text" id="name" name="name" required> <br> <input type="submit" value="Create"> </form>
  11. <turbo-stream action="append" target="todolistTable"> <template> <tr id="123-row"> <td><a href="/todos/123">Todo</a></td> <td>Open</td> <td>

    <form action="/todos/stream/123" method="POST" enctype="multipart/form-data"> <input type="submit" value="Done"> </form> </td> </tr> </template> </turbo-stream> <turbo-stream action="remove" target="no-todos"></turbo-stream> text/vnd.turbo-stream.html
  12. CONNECTING TO EVENT STREAMS <script type="text/javascript"> if (window["EventSource"] && window["Turbo"])

    { Turbo.connectStreamSource(new EventSource("/todos/sse/connect")); } else { console.warn("Turbo Streams over SSE not available"); } </script>
  13. WOW THAT’S PRETTY COOL! SERVER SIDE RENDERING WITHOUT FULL RELOADS!

    SUCH A GREAT USER EXPERIENCE! IT’S SO FAST! HOTWIRE IS SO EASY TO LEARN AND INTEGRATES WELL WITH OUR QUARKUS SETUP! FRONTEND DEVELOPMENT JUST BECAME A JOY!
  14. REFERENCES • Images: • Photo by Lautaro Andreani • Photo

    by Glenn Carstens-Peters • Photo by Rob Laughter