github statelyai/xstate xstate@4.9.0

4 years ago

Minor Changes

  • f3ff150 #1103 Thanks @davidkpiano! - Simplify the TransitionConfigArray and TransitionConfigMap types in order to fix excessively deep type instantiation TypeScript reports. This addresses #1015.

  • 6c47b66 #1076 Thanks @Andarist! - Added support for conditional actions. It's possible now to have actions executed based on conditions using following:

    entry: [
      choose([
        { cond: ctx => ctx > 100, actions: raise('TOGGLE') },
        {
          cond: 'hasMagicBottle',
          actions: [assign(ctx => ({ counter: ctx.counter + 1 }))]
        },
        { actions: ['fallbackAction'] }
      ])
    ];

    It works very similar to the if-else syntax where only the first matched condition is causing associated actions to be executed and the last ones can be unconditional (serving as a general fallback, just like else branch).

Patch Changes

  • 1a129f0 #1073 Thanks @Andarist! - Cleanup internal structures upon receiving termination events from spawned actors.

  • e88aa18 #1085 Thanks @Andarist! - Fixed an issue with data expressions of root's final nodes being called twice.

  • 88b17b2 #1090 Thanks @rjdestigter! - This change carries forward the typestate type information encoded in the arguments of the following functions and assures that the return type also has the same typestate type information:

    • Cloned state machine returned by .withConfig.
    • .state getter defined for services.
    • start method of services.
  • d5f622f #1069 Thanks @davidkpiano! - Loosened event type for SendAction<TContext, AnyEventObject>

Don't miss a new xstate release

NewReleases is sending notifications on new releases.