Skip to content

TLDR #2

@incepter

Description

@incepter

What is this

This is a React framework inspired by the spring framework ecosystem.

It aims to work declaratively using decorators to mark 'parts' of the system with some behavior. For example, to declare a route returning a ReactELement you can do:

@Get('/users')
async UsersList({query}) {
  let data = await queryUsers(query)
  return <UsersListComponent data={data} />
}

This is a basic example of how the framework will allow you to write code.

Core philosophy

The core philosophy is that the previous code should work in all react environments: CSR, SSR and RSC.

  • RSC: Using RSC, components may have UseServer or UseClient to instruct the bundler to keep the files under a certain isolation.

  • SSR: Full html (no js) and/or hydration. Depending on the mode, your component is rendered in the server and hydrated on the client.

  • CSR: It will be completely rendered on the client

Decorators

Framework API marking:

  • Resource: Routes will be inside this class
  • Configuration: Filters and config will be inside this class

Routing

The following decorators will be used to mark the decorated function as a router entry, they can customize the response type (text/html, application/json, stream, blob...)

  • Get
  • Put
  • Post
  • Patch
  • Delete
  • Options

Behavior

  • Filter: will define a WebFilter that will be invoked at each route
  • PreAuthorize: will prevent a user from rendering a component based on authorizations

Render

  • Render: says that we render a component, so the extraction will be to a .tsx file
  • UseServer: will be a RSC
  • UseClient: will be a RCC
  • Loading: will define the loading component when route is loading
  • ErrorBoundary: will be rendered when an error occurs in the route elements

Context

  • Bean: will define a bean by name
  • Inject: will allow injecting a bean by name

Bundling/transpilation

Here is how this will work after writing code:

  1. @resource and @configuration will be scanned in the entire project

  2. Routing will be deducted from the configured Resources

image

  1. Each route will be moved to its own file according to the decorators it has

image

  1. An entry point will be generated depending on the build target (csr, ssr or rsc)

(TO BE CONTINUED)

Routing

Runtime

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions