brisa-build / brisa

The Web Platform Framework.
https://brisa.build
MIT License
452 stars 12 forks source link

feat: rename `renderIndicator` to `indicator` and add new features #585

Closed aralroca closed 1 month ago

aralroca commented 1 month ago

Fixes https://github.com/brisa-build/brisa/issues/584


Initiator

Similar to an enum, Initiator is an object that contains the following properties:

Example usage:

In the next example, we use Initiator to determine if the render was initiated by a server action.

import { Initiator } from "brisa";

export default function MyComponent(props, { initiator }) {
  const isAnAction = initiator === Initiator.SERVER_ACTION;
  return (
    <div>
      {isAnAction
        ? "This is a rerender from an action"
        : "Another type of render"}
    </div>
  );
}

Types:

export interface InitiatorType {
  readonly INITIAL_REQUEST: "INITIAL_REQUEST";
  readonly SPA_NAVIGATION: "SPA_NAVIGATION";
  readonly SERVER_ACTION: "SERVER_ACTION";
  readonly API_REQUEST: "API_REQUEST";
}

export const Initiator: InitiatorType;
pkg-pr-new[bot] commented 1 month ago

Open in Stackblitz

brisa-adapter-vercel

``` bun add https://pkg.pr.new/brisa-build/brisa/brisa-adapter-vercel@585 ```

brisa

``` bun add https://pkg.pr.new/brisa-build/brisa@585 ```

brisa-tailwindcss

``` bun add https://pkg.pr.new/brisa-build/brisa/brisa-tailwindcss@585 ```

create-brisa

``` bun add https://pkg.pr.new/brisa-build/brisa/create-brisa@585 ```

brisa-pandacss

``` bun add https://pkg.pr.new/brisa-build/brisa/brisa-pandacss@585 ```

www

``` bun add https://pkg.pr.new/brisa-build/brisa/www@585 ```

commit: c839fb8