Hacker News new | ask | show | jobs
by just_haug 806 days ago
I suppose it depends on what you mean as a growing app. A few of the examples (https://github.com/yolmio/boost/tree/main/examples) are apps that you could easily sell as a freelancer/contract work.

You can of course split up your system into as many files as possible, the emphasis on a single file is that now instead of your architecture, languages, etc. enforcing separate files and hampering reuse, you can organize it however you like.

I'm sure best practices will evolve overtime, but I've been alright with just a single file for apps in production (as long as the majority of components are made reusable)

1 comments

> I suppose it depends on what you mean as a growing app. A few of the examples are apps that you could easily sell as a freelancer/contract work.

The examples are interesting but what I don't see in your docs is how to control UI. Is that driven entirely by data types? What happens when an app wants/needs novel UI/flow?

The UI is essentially a node tree similar to react, defined in JSON objects.

This example (https://github.com/yolmio/boost/blob/main/examples/todos/sys...) gives a "lower level" example of a todo list that interacts with the database.

But excerpted the below demonstrates the state approach:

  nodes.state({
    procedure: (s) =>
      s
        // A scalar is a single value
        .scalar(`input_text`, `''`)
        // Queries the todo table from the database and puts them in a ui table
        .table(`todo`, `select * from db.todo`),
    children: [
      // like react, controlled input
      components.input({
        value: `input_text`,
        on: { input: (s) => s.setScalar(`input_text`, `target_value`) },
      }),
      components.button({
        on: {
          click: (s) =>
            s.serviceProc((s) =>
              s
                .startTransaction()
                // Inserts into the database using the scalar defined in the ui
                .modify(`insert into db.todo (title) values (input_text)`)
                .commitTransaction(),
            ),
        },
      }),
    ],
  });

It defines a node hierarchy with ui state (tables) and that state is populated from the database. The serviceProc is able to modify the database with data from the ui state.

There is nothing special about any of the components and functions I call in the examples, there are really just creating node hierarchies and objects. It means that you aren't limited to kinds of UIs you can create and you can create your own functions that just take in data and return arbitrary node hierarchies.