question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"$$initial" event discussion.

See original GitHub issue

Hey @devanshj, in this example, TypeScript is erroring because of the “$$initial” event:

const [machine, send] = useStateMachine({
  schema: {
    context: t<{time: number}>(),
    events: {
      STOP: t<{resetTime: number}>()
    }
  },
  context: {time: 0},
  initial: 'idle',
  states: {
    idle: {
      on: {
        START: 'running',
      },
      effect({setContext, event}) {
        setContext(() => ({ time: event?.resetTime }));
//                                       ^- Property 'resetTime' does not exist on type '{ type: "$$initial"; }'
      },
    },
    running: {
      on: {
        STOP: 'idle',
      }
    }
  },
});

send({ type: 'STOP', resetTime: 10 });

I think it might be confusing for the user to understand what’s going on here. And since so far we’re not really using the initial event to trigger anything, I’m thinking of reverting back to start undefined. Any objections?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
cassiozencommented, Jul 28, 2021

Ah, on a different note: I merged the beta branch into main. I’m using Github’s wiki for documentation, and it’s not branch-based: Since I’m updating them I might as well make the development happen on main.

In the future I might need a different documentation solution.

0reactions
devanshjcommented, Jul 28, 2021

It does make sense. closing, let’s keep the initial event.

Ha nice! A little late, already got another counter xD

Read more comments on GitHub >

github_iconTop Results From Across the Web

All together now: Event formats for discussions - Social in silico
In-person discussions provide a chance to hear multiple viewpoints and to delve into detailed arguments that aren't easy to present online.
Read more >
successful discussion events | Science Museum Group
Practical tips on running effective discussion events with adults and schools. When you're planning the event content… Choose a topic that is controversial, ......
Read more >
5 Steps for Hosting Your First Successful Event - Scandiweb
We have compiled an event (meetup, workshop, conference) organization strategy that works, with a couple of tools to help you along the way....
Read more >
How to Plan an Event: a Complete Guide - Wild Apricot
The very first step in planning your event is to establish tangible goals and objectives. Start by asking yourself: Why are you organizing...
Read more >
17 Tips for Turning First-Time Attendees into Event Regulars
Create a discussion group in your online community for first-time attendees. Ask staff or volunteers to moderate the discussion and answer questions. #6....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found