Actor-based state management & orchestration for complex app logic.
MIT License
Bot releases are visible (Hide)
Published by github-actions[bot] about 1 year ago
#4036 e2440f0b1
Thanks @davidkpiano! - Actor types can now be specified in the .types
property of createMachine
:
const fetcher = fromPromise(() => fetchUser());
const machine = createMachine({
types: {} as {
actors: {
src: 'fetchData'; // src name (inline behaviors ideally inferred)
id: 'fetch1' | 'fetch2'; // possible ids (optional)
logic: typeof fetcher;
};
},
invoke: {
src: 'fetchData', // strongly typed
id: 'fetch2', // strongly typed
onDone: {
actions: ({ event }) => {
event.output; // strongly typed as { result: string }
}
},
input: { foo: 'hello' } // strongly typed
}
});
#4157 31eb5f8a1
Thanks @Valkendorm! - Merge sendBack
and receive
with other properties of fromCallback
logic creator.
const callbackLogic = fromCallback(({ input, system, self, sendBack, receive }) => { ... });
Published by github-actions[bot] about 1 year ago
Published by github-actions[bot] about 1 year ago
#4049 afc690046
Thanks @davidkpiano! - If context types are specified in the machine config, the context
property will now be required:
// ❌ TS error
createMachine({
types: {} as {
context: { count: number };
}
// Missing context property
});
// ✅ OK
createMachine({
types: {} as {
context: { count: number };
},
context: {
count: 0
}
});
#4117 c7c3cb459
Thanks @davidkpiano! - Actor logic creators now have access to self
:
const promiseLogic = fromPromise(({ self }) => { ... });
const observableLogic = fromObservable(({ self }) => { ... });
const callbackLogic = fromCallback((sendBack, receive, { self }) => { ... });
const transitionLogic = fromTransition((state, event, { self }) => { ... }, ...);
Published by github-actions[bot] over 1 year ago
Published by github-actions[bot] over 1 year ago
#4130 e659fac5d
Thanks @davidkpiano! - The pure(...)
action creator is now properly typed so that it allows function actions:
actions: pure(() => [
// now allowed!
(context, event) => { ... }
])
Published by github-actions[bot] over 1 year ago
Published by github-actions[bot] over 1 year ago
Published by github-actions[bot] over 1 year ago
Published by github-actions[bot] over 1 year ago
Published by github-actions[bot] over 1 year ago
#4127 cdaddc266
Thanks @Andarist! - IDs for delayed events are no longer derived from event types so this won't work automatically:
entry: raise({ type: 'TIMER' }, { delay: 200 });
exit: cancel('TIMER');
Please use explicit IDs:
entry: raise({ type: 'TIMER' }, { delay: 200, id: 'myTimer' });
exit: cancel('myTimer');
#4127 cdaddc266
Thanks @Andarist! - All builtin action creators (assign
, sendTo
, etc) are now returning functions. They exact shape of those is considered an implementation detail of XState and users are meant to only pass around the returned values.
Published by github-actions[bot] over 1 year ago
#4050 fc88dc8e6
Thanks @davidkpiano! - The options
prop has been added (back) to the Context.Provider
component returned from createActorContext
:
const SomeContext = createActorContext(someMachine);
// ...
<SomeContext.Provider options={{ input: 42 }}>
{/* ... */}
</SomeContext.Provider>;
fc88dc8e6
Thanks @davidkpiano! - The observerOrListener
argument has been removed from the 3rd argument of createActorContext(logic, options)
.Published by github-actions[bot] over 1 year ago
Published by github-actions[bot] over 1 year ago
#4080 94526df03
Thanks @davidkpiano! - The machine.options
property has been renamed to machine.implementations
#4078 43fcdecf2
Thanks @Andarist! - Fixed spawned actors cleanup when multiple actors were spawned without explicit IDs assigned to them.
#4083 163528529
Thanks @Andarist! - Remove State['changed']
. A new instance of State
is being created if there are matching transitions for the received event. If there are no matching transitions then the current state is being returned.
#4064 047897265
Thanks @davidkpiano! - Guard objects can now reference other guard objects:
const machine = createMachine(
{
initial: 'home',
states: {
home: {
on: {
NEXT: {
target: 'success',
guard: 'hasSelection'
}
}
},
success: {}
}
},
{
guards: {
// `hasSelection` is a guard object that references the `stateIn` guard
hasSelection: stateIn('selected')
}
}
);
Published by github-actions[bot] over 1 year ago
#4098 ae7691811
Thanks @davidkpiano! - The log
, pure
, choose
, and stop
actions were added to the main export:
import { log, pure, choose, stop } from 'xstate';
Published by github-actions[bot] over 1 year ago
#4065 3b4b1305a
Thanks @benblank! - This change adds support for using "*" as a wildcard event type in machine configs.
Because that event type previously held no special meaning, it was allowed as an event type both in configs and when transitioning and matched as any other would. As a result of changing it to be a wildcard, any code which uses "*" as an ordinary event type will break, making this a major change.
Published by github-actions[bot] over 1 year ago
50fe8cdd4
Thanks @davidkpiano! - Instances of "behavior" in the codebase have been replaced with "actor logic".Published by github-actions[bot] over 1 year ago
50fe8cdd4
Thanks @davidkpiano! - Instances of "behavior" in the codebase have been replaced with "actor logic".Published by github-actions[bot] over 1 year ago
#4018 c59bb6a72
Thanks @Andarist! - machine.initialState
has been removed, you can use machine.getInitialState(...)
instead
#4018 c59bb6a72
Thanks @Andarist! - machine.transition(...)
and machine.getInitialState(...)
require now an actorContext
argument
#4063 e1f633ac9
Thanks @Andarist! - Removed State['transitions']
.
#4018 c59bb6a72
Thanks @Andarist! - machine.transition
no longer accepts state values. You have to resolve the state value to a State
before passing it to machine.transition
#4041 50fe8cdd4
Thanks @davidkpiano! - Instances of "behavior" in the codebase have been replaced with "actor logic".
#4055 eb7c8b387
Thanks @davidkpiano! - The system
can now be accessed in all available actor logic creator functions:
fromPromise(({ system }) => { ... });
fromTransition((state, event, { system }) => { ... });
fromObservable(({ system }) => { ... });
fromEventObservable(({ system }) => { ... });
fromCallback((sendBack, receive, { system }) => { ... });
#4059 bbea3bc4d
Thanks @Andarist! - Removed State['actions']
. Actions are considered to be a side-effect of a transition, things that happen in the moment and are not meant to be persisted beyond that.
Published by github-actions[bot] over 1 year ago
Published by github-actions[bot] over 1 year ago