Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify event choices #22

Merged
merged 7 commits into from
Mar 16, 2024
Merged

Conversation

davidkpiano
Copy link
Member

@davidkpiano davidkpiano commented Mar 15, 2024

The createSchemas(…) function has been removed. The defineEvents(…) function should be used instead, as it is a simpler way of defining events and event schemas using Zod:

import { defineEvents } from '@statelyai/agent';
import { z } from 'zod';
import { setup } from 'xstate';

const events = defineEvents({
  inc: z.object({
    by: z.number().describe('Increment amount'),
  }),
});

const machine = setup({
  types: {
    events: events.types,
  },
  schema: {
    events: events.schemas,
  },
}).createMachine({
  // ...
});

@davidkpiano davidkpiano merged commit 1424f03 into main Mar 16, 2024
@github-actions github-actions bot mentioned this pull request Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant