Ingrates
API Guide Ecosystem Github

Ingrates

Async


Make use of the actor model to simplify complex async workloads, encapsulate your logic and communicate with decoupled messages

Safe


Each actor runs in isolation so errors are contained, one actor crashing doesn't mean catastrophe

Portable


Runs the same on the server and the browser (with no build step), and provides great tooling for communication between the two

import createActorSystem from "@little-bonsai/ingrates";

async function* ChildActor({ parent, dispatch }, firstname, lastname) {
  const msg = yield;

  if (msg.type === "HELLO") {
    dispatch(msg.src, {
      type: "GOODBYE",
      msg: `say goodbye to ${firstname} ${lastname}`,
    });
  }
}

async function* RootActor({ spawn, self, dispatch }) {
  const myChild = spawn(ChildActor, "Bert", "Jurnegen");

  dispatch(myChild, { type: "HELLO" });

  while (true) {
    const msg = yield;
    if (msg.type === "GOODBYE") {
      console.log("Please... my son. He's very sick");
    }
  }
}


createActorSystem()(RootActor);

Getting Started

If you're just getting started with ingrates, you should start with The Guide which will walk you through the ideas used in ingrates. You can then visit The Ecosystem page to take a look at some of the other packages that use or extend ingrates.