How to Build a Calculator With Hotwire and No Javascript

Поделиться
HTML-код
  • Опубликовано: 18 ноя 2024

Комментарии • 13

  • @ritec
    @ritec 2 года назад

    Great tutorial, thanks. Hotwire does have a ton of potential, the fact this was done without touching any JS is amazing.

  • @kukunin1
    @kukunin1 2 года назад

    Great videos, high quality! One improvement is to remove the #result attribute and simplify the rendering logic. #result can be replaced with just the left operand

  • @dudewhatthehellman
    @dudewhatthehellman 2 года назад

    This seems almost absurdly complicated for what it is. Might make more sense to do it in JS but it’s good to know this option exists.

  • @crengela
    @crengela 2 года назад

    Thanks Cezar!

  • @JuanVqz
    @JuanVqz 2 года назад +1

    Thank you for sharing it, I wonder if it is possible to sum 1+49

    • @mixandgo
      @mixandgo  2 года назад +1

      Sure, you'd have to change the logic a bit though. Maybe add an = sign to signify you're done adding numbers.

    • @volonterx
      @volonterx 2 года назад +1

      I think next step is to replase array of values with a string that incremented with new symbol after a button click. This string also may be printed on the calculator screen. Backend should parse it to perform morse complex calculations.

  • @edenlandau6426
    @edenlandau6426 2 года назад +1

    This is cool, but wouldn't this be impractically slow across a network if you have to make a roundtrip for every button click?

    • @mixandgo
      @mixandgo  2 года назад

      This particular example is slower because it responds with the entire page, but you can trim down the response to just the result div, which would very fast over websockets.
      I don't know what the exact benchmarks look like, but I would imagine the JS version would be faster to execute.

    • @PeterCooperUK
      @PeterCooperUK 2 года назад +1

      It's reasonable to think that, but if you consider that a 3D multiplayer game is essentially doing a similar thing with hundreds of data points per second over a network, even 100 people simultaneously hammering away on a calculator like this is unlikely to tax a small server instance :)

  • @captaclientes3074
    @captaclientes3074 Год назад

    what is your vscode theme?

    • @mixandgo
      @mixandgo  Год назад +1

      I'm not 100%, sure, but I think it was "Community Material Palenight High Contrast".

    • @captaclientes3074
      @captaclientes3074 Год назад

      @@mixandgo thanks!