Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I just started working on something like this. It's a VDOM implemented in Ruby and it streams updates to the browser via Server-Sent Events which are then applied by a tiny bit of JavaScript.

A basic counter component would look something like this:

    initial_state do |props|
      { count: 0 }
    end

    handler(:increment) do |e|
      update do |count:|
        { count: count + 1 }
      end
    end

    render do
      <div>
        <p>Count: {state[:count]}</p>
        <button on-click={handler(:increment)}>Increment</button>
      </div>
    end
There are some things I'm used to in the JavaScript world that I'm trying to introduce here. I got hot reloading which is pretty cool. And CSS modules... and static typing with Sorbet.

Events are handled on the server, so there's no need for an API... You could just talk to your database directly in your onsubmit-handler. I think that might be the largest benefit from using something like this.

If the app is deployed in a region close to you, you won't barely notice the latency.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: