-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Version Packages (alpha) #902
Conversation
25a01c3
to
93a0d8f
Compare
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 9b28377:
|
2f36204
to
3a6a6b0
Compare
545a5a8
to
1f3bcce
Compare
81244f9
to
752b6d5
Compare
6b42438
to
f57f739
Compare
f1f9f1a
to
2d51976
Compare
b985519
to
3ee090b
Compare
eba57c4
to
5ce7779
Compare
5ce7779
to
73632ae
Compare
1042a44
to
6200a3a
Compare
6200a3a
to
bacc92b
Compare
9292cf9
to
4976ced
Compare
4976ced
to
ff6795c
Compare
ff6795c
to
a47a3e9
Compare
a47a3e9
to
52aa919
Compare
0c89c96
to
98a7202
Compare
9b93e3d
to
960776b
Compare
960776b
to
aa3e8f1
Compare
aa3e8f1
to
e95f0dc
Compare
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit e95f0dc:
|
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to next, this PR will be updated.
next
is currently in pre mode so this branch has prereleases rather than normal releases. If you want to exit prereleases, runchangeset pre exit
onnext
.Releases
[email protected]
Major Changes
#1045
7f3b84816
Thanks @davidkpiano! - - The third argument ofmachine.transition(state, event)
has been removed. Thecontext
should always be given as part of thestate
.There is a new method:
machine.microstep(state, event)
which returns the resulting intermediateState
object that represents a single microstep being taken when transitioning fromstate
via theevent
. This is theState
that does not take into account transient transitions nor raised events, and is useful for debugging.The
state.events
property has been removed from theState
object, and is replaced internally bystate._internalQueue
, which represents raised events to be processed in a macrostep loop. Thestate._internalQueue
property should be considered internal (not used in normal development).The
state.historyValue
property now more closely represents the original SCXML algorithm, and is a mapping of state node IDs to their historic descendent state nodes. This is used for resolving history states, and should be considered internal.The
stateNode.isTransient
property is removed fromStateNode
.The
.initial
property of a state node config object can now contain executable content (i.e., actions):assign()
) will now be executed "in order", rather than automatically prioritized. They will be evaluated after previously defined actions are evaluated, and actions that read fromcontext
will have those intermediate values applied, rather than the final resolved value of allassign()
actions taken, which was the previous behavior.This shouldn't change the behavior for most state machines. To maintain the previous behavior, ensure that
assign()
actions are defined before any other actions.#1669
969a2f4fc
Thanks @davidkpiano! - An error will be thrown if aninitial
state key is not specified for compound state nodes. For example:You will get the error:
#2294
c0a6dcafa
Thanks @davidkpiano! - The machine'scontext
is now restricted to anobject
. This was the most common usage, but now the typings preventcontext
from being anything but an object:If
context
isundefined
, it will now default to an empty object{}
:#1260
172d6a7e1
Thanks @davidkpiano! - All generic types containingTContext
andTEvent
will now follow the same, consistent order:TContext
TEvent
TStateSchema,
TTypestate`, etc.#1808
31bc73e05
Thanks @davidkpiano! - Renamedmachine.withConfig(...)
tomachine.provide(...)
.#878
e09efc720
Thanks @Andarist! - Removed third parameter (context) from Machine's transition method. If you want to transition with a particular context value you should create appropriateState
usingState.from
. So instead of this -machine.transition('green', 'TIMER', { elapsed: 100 })
, you should do this -machine.transition(State.from('green', { elapsed: 100 }), 'TIMER')
.#1203
145539c4c
Thanks @davidkpiano! - - Theexecute
option for an interpreted service has been removed. If you don't want to execute actions, it's recommended that you don't hardcode implementation details into the basemachine
that will be interpreted, and extend the machine'soptions.actions
instead. By default, the interpreter will execute all actions according to SCXML semantics (immediately upon transition).xstate/devTools/redux
:By default, dev tools are attached to the global
window.__xstate__
object:And creating your own custom dev tools adapter is a function that takes in the
service
:These handlers have been removed, as they are redundant and can all be accomplished with
.onTransition(...)
and/or.subscribe(...)
:service.onEvent()
service.onSend()
service.onChange()
The
service.send(...)
method no longer returns the next state. It is avoid
function (fire-and-forget).The
service.sender(...)
method has been removed as redundant. Useservice.send(...)
instead.#953
3de36bb24
Thanks @davidkpiano! - Support for getters as a transition target (instead of referencing state nodes by ID or relative key) has been removed.The
Machine()
andcreateMachine()
factory functions no longer support passing incontext
as a third argument.The
context
property in the machine configuration no longer accepts a function for determining context (which was introduced in 4.7). This might change as the API becomes finalized.The
activities
property was removed fromState
objects, as activities are now part ofinvoke
declarations.The state nodes will not show the machine's
version
on them - theversion
property is only available on the root machine node.The
machine.withContext({...})
method now permits providing partial context, instead of the entire machine context.#1443
9e10660ec
Thanks @davidkpiano! - Thein: ...
property for transitions is removed and replaced with guards. It is recommended to usestateIn()
andnot(stateIn())
guard creators instead:#1456
8fcbddd51
Thanks @davidkpiano! - There is now support for higher-level guards, which are guards that can compose other guards:and([guard1, guard2, /* ... */])
returnstrue
if all guards evaluate to truthy, otherwisefalse
or([guard1, guard2, /* ... */])
returnstrue
if any guard evaluates to truthy, otherwisefalse
not(guard1)
returnstrue
if a single guard evaluates tofalse
, otherwisetrue
#2824
515cdc9c1
Thanks @davidkpiano! - Actions and guards that follow eventless transitions will now receive the event that triggered the transition instead of a "null" event ({ type: '' }
), which no longer exists:#1240
6043a1c28
Thanks @davidkpiano! - Thein: '...'
transition property can now be replaced withstateIn(...)
andstateNotIn(...)
guards, imported fromxstate/guards
:The
stateIn(...)
andstateNotIn(...)
guards also can be used the same way asstate.matches(...)
:An error will now be thrown if the
assign(...)
action is executed when thecontext
isundefined
. Previously, there was only a warning.The SCXML event
error.execution
will be raised if assignment in anassign(...)
action fails.Error events raised by the machine will be thrown if there are no error listeners registered on a service via
service.onError(...)
.#2824
6a6b2b869
Thanks @davidkpiano! - Eventless transitions must now be specified in thealways: { ... }
object and not in theon: { ... }
object:#2484
0b49437b1
Thanks @davidkpiano! - Parameterized actions now require aparams
property:#987
0e24ea6d6
Thanks @davidkpiano! - Theinternal
property will no longer have effect for transitions on atomic (leaf-node) state nodes. In SCXML,internal
only applies to complex (compound and parallel) state nodes:#987
04e89f90f
Thanks @davidkpiano! - The history resolution algorithm has been refactored to closely match the SCXML algorithm, which changes the shape ofstate.historyValue
to map history state node IDs to their most recently resolved target state nodes.#2882
0096d9f7a
Thanks @davidkpiano! - Thestate.history
property has been removed. This does not affect the machine "history" mechanism.Storing previous state should now be done explicitly:
#1456
8fcbddd51
Thanks @davidkpiano! - BREAKING: Thecond
property in transition config objects has been renamed toguard
. This unifies terminology for guarded transitions and guard predicates (previously called "cond", or "conditional", predicates):#2060
b200e0e0b
Thanks @davidkpiano! - TheMachine()
function has been removed. Use thecreateMachine()
function instead.#3148
7a68cbb61
Thanks @davidkpiano! -spawn
is no longer importable fromxstate
. Instead you get it inassign
like this:In addition to that, you can now
spawn
actors defined in your implementations object, in the same way that you were already able to do that withinvoke
. To do that just reference the defined actor like this:#2869
9437c3de9
Thanks @davidkpiano! - Theservice.batch(events)
method is no longer available.#2191
0038c7b1e
Thanks @davidkpiano! - TheStateSchema
type has been removed from all generic type signatures.#3148
7a68cbb61
Thanks @davidkpiano! -EmittedFrom
type helper has been renamed toSnapshotFrom
.#1163
390eaaa52
Thanks @davidkpiano! - Breaking: Thestate.children
property is now a mapping of invoked actor IDs to theirActorRef
instances.Breaking: The way that you interface with invoked/spawned actors is now through
ActorRef
instances. AnActorRef
is an opaque reference to anActor
, which should be never referenced directly.Breaking: The
origin
of anSCXML.Event
is no longer a string, but anActorRef
instance.#3148
7a68cbb61
Thanks @davidkpiano! - Theservices
option passed as the second argument tocreateMachine(config, options)
is renamed toactors
. Each value inactors
should be a function that takes incontext
andevent
and returns a [behavior](TODO: link) for an actor. The provided behavior creators are:fromMachine
fromPromise
fromCallback
fromObservable
fromEventObservable
#878
e09efc720
Thanks @Andarist! - Support for compound string state values has been dropped from Machine's transition method. It's no longer allowed to call transition like this -machine.transition('a.b', 'NEXT')
, instead it's required to use "state value" representation like this -machine.transition({ a: 'b' }, 'NEXT')
.#898
025a2d6a2
Thanks @davidkpiano! - - Breaking: activities removed (can be invoked)Since activities can be considered invoked services, they can be implemented as such. Activities are services that do not send any events back to the parent machine, nor do they receive any events, other than a "stop" signal when the parent changes to a state where the activity is no longer active. This is modeled the same way as a callback service is modeled.
#878
e09efc720
Thanks @Andarist! - Removed previously deprecated config properties:onEntry
,onExit
,parallel
andforward
.#2876
c99bb43af
Thanks @davidkpiano! - Typings forTypestate
have been removed. The reason for this is that types for typestates needed to be manually specified, which is unsound because it is possible to specify impossible typestates; i.e., typings for a state'svalue
andcontext
that are impossible to achieve.#2840
fc5ca7b7f
Thanks @davidkpiano! - Invoked/spawned actors are no longer available onservice.children
- they can only be accessed fromstate.children
.#1811
5d16a7365
Thanks @davidkpiano! - Prefix wildcard event descriptors are now supported. These are event descriptors ending with".*"
which will match all events that start with the prefix (the partial event type before".*"
):Note: wildcards are only valid as the entire event type (
"*"
) or at the end of an event type, preceded by a period (".*"
):"*"
"event.*"
"event.something.*"
"event.*.something"
"event*"
"event*.some*thing"
"*.something"
#1456
8fcbddd51
Thanks @davidkpiano! - The interface for guard objects has changed. Notably, all guard parameters should be placed in theparams
property of the guard object:Example taken from Custom Guards:
#1054
53a594e9a
Thanks @Andarist! -Machine#transition
no longer handles invalid state values such as values containing non-existent state regions. If you rehydrate your machines and change machine's schema then you should migrate your data accordingly on your own.#1002
31a0d890f
Thanks @Andarist! - Removed support forservice.send(type, payload)
. We are usingsend
API at multiple places and this was the only one supporting this shape of parameters. Additionally, it had not strict TS types and using it was unsafe (type-wise).Minor Changes
#3148
7a68cbb61
Thanks @davidkpiano! -onSnapshot
is now available for invoke configs. You can specify a transition there to be taken when a snapshot of an invoked actor gets updated. It works similarly toonDone
/onError
.#1041
b24e47b9e
Thanks @Andarist! - Support for specifying states deep in the hierarchy has been added for theinitial
property. It's also now possible to specify multiple states as initial ones - so you can enter multiple descandants which have to be parallel to each other. Keep also in mind that you can only target descendant states with theinitial
property - it's not possible to target states from another regions.Those are now possible:
#1028
0c6cfee9a
Thanks @Andarist! - Added support for expressions tocancel
action.#898
c9cda27cb
Thanks @davidkpiano! - Added interop observable symbols toActorRef
so that actor refs are compatible with libraries like RxJS.@xstate/[email protected]
Major Changes
7a68cbb61
Thanks @davidkpiano! - RemovedgetSnapshot
parameter from hooks. It is expected that the receivedactorRef
has to have agetSnapshot
method on it that can be used internally.Patch Changes
7f3b84816
,969a2f4fc
,c0a6dcafa
,7a68cbb61
,172d6a7e1
,31bc73e05
,e09efc720
,145539c4c
,3de36bb24
,9e10660ec
,8fcbddd51
,515cdc9c1
,6043a1c28
,6a6b2b869
,0b49437b1
,0e24ea6d6
,04e89f90f
,0096d9f7a
,8fcbddd51
,b200e0e0b
,7a68cbb61
,9437c3de9
,0038c7b1e
,7a68cbb61
,b24e47b9e
,390eaaa52
,7a68cbb61
,0c6cfee9a
,e09efc720
,025a2d6a2
,e09efc720
,c99bb43af
,fc5ca7b7f
,c9cda27cb
,5d16a7365
,8fcbddd51
,53a594e9a
,31a0d890f
]:@xstate/[email protected]
Major Changes
7a68cbb61
Thanks @davidkpiano! - RemovedgetSnapshot
parameter from composables. It is expected that the receivedactorRef
has to have agetSnapshot
method on it that can be used internally.Patch Changes
7f3b84816
,969a2f4fc
,c0a6dcafa
,7a68cbb61
,172d6a7e1
,31bc73e05
,e09efc720
,145539c4c
,3de36bb24
,9e10660ec
,8fcbddd51
,515cdc9c1
,6043a1c28
,6a6b2b869
,0b49437b1
,0e24ea6d6
,04e89f90f
,0096d9f7a
,8fcbddd51
,b200e0e0b
,7a68cbb61
,9437c3de9
,0038c7b1e
,7a68cbb61
,b24e47b9e
,390eaaa52
,7a68cbb61
,0c6cfee9a
,e09efc720
,025a2d6a2
,e09efc720
,c99bb43af
,fc5ca7b7f
,c9cda27cb
,5d16a7365
,8fcbddd51
,53a594e9a
,31a0d890f
]: