Solid · guides

How to do things with Solid.

Each guide is a file you can run, set in the theatre’s world. What it prints is what the installed package printed.

First steps.

A booking arrives in three pieces, the way a model sends it, and the file prints the object after each piece.

Install it
pnpm add @niscorp/solid zod
Run it
npx tsx first.mts
Write first.mts
import { createStream } from '@niscorp/solid';
import { z } from 'zod';

const schema = z.object({ member: z.string(), play: z.string(), seats: z.number() });
const stream = createStream({ schema, initial: { member: '', play: '', seats: 0 } });

stream.select('play').onFinal((play) => console.log('play is done:', play));

for (const chunk of ['{"member":"Gra', 'ce","play":"The Tem', 'pest","seats":2}']) {
  stream.write(chunk);
  console.log(stream.current());
}
stream.close();
It prints
{ member: 'Gra', play: '', seats: 0 }
{ member: 'Grace', play: 'The Tem', seats: 0 }
play is done: The Tempest
{ member: 'Grace', play: 'The Tempest', seats: 2 }

After every piece there is a whole object of the schema’s shape to draw. The third line is onFinal: the play was finished when the next key began, before the reply was.

Then, one at a time.

Each is a file of its own and adds one thing. Read them in order, or go to the one you need.