-
#119
743433d
Thanks @tivac! - Support multiple invoked items per statePreviously it would only use the last invocation at each state.
-
#117
0cec0db
Thanks @tivac! - Add machine info to each resultOtherwise root components of parallel sibling child machines can end up not being actually comparable.
[ [Object: null prototype] { + machine: "(machine).child-one", path: false, component: [Function: child], props: false, children: [] }, [Object: null prototype] { + machine: "(machine).child-two", path: false, component: [Function: child], props: false, children: [] } ]
-
#115
51cfe5e
Thanks @tivac! - Fix an issue where in specific situations child trees would not be built.If a child machine has an
invoke
that immediately triggers a no-op event, theComponentTree
instance wouldn't actually walk that child machine for components to render. This was due to an interesting interaction between the xstate.changed
property and wheninvoke
s within the statechart are run.Now whenever the
ComponentTree
sees a new machine it hasn't walked is running, it will walk it.
-
#111
a0ec633
Thanks @tivac! - Add.d.ts
files to releases and restructure exports.import ComponentTree from "xstate-component-tree"; import componentHelper from "xstate-component-tree/component";
import { ComponentTree, componentHelper } from "xstate-component-tree";
-
#113
88d1dba
Thanks @tivac! - Component helper preserves.meta
fieldsPrevious using the helper like this:
helper(Component, { meta: { fooga: "wooga", }, });
would return an object with no
meta.fooga
property. Now those keys are properly preserved if they exist.meta.load
will still be overwritten if it exists, because it is required for the helper to function. A warning if it exists may be introduced in a future release.
-
#98
e7cd20d
Thanks @tivac! - Support for components at the root of machinescreateMachine({ initial: "foo", meta: { component: RootComponent, }, states: { foo: { meta: { component: FooComponent, }, }, }, });
Previously
RootComponent
would be ignored, now it will be the first component in the tree andFooComponent
will be placed as a child of it.
-
#74
951cea7
Thanks @tivac! - Adding.can()
API from XStateThe
.can()
API is a simple passthrough to the interpreter for the root statechart being managed byxstate-component-tree
, and is intended as a convenience function to make it easier to interact with a ComponentTree instance instead of a direct XState Interpreter reference.From the XState docs on
.can()
:Determines whether sending the event will cause a non-forbidden transition to be selected, even if the transitions have no actions nor change the state value.
-
#69
b6c9fc8
Thanks @tivac! - Always provide a valid initial value to subscribersPreviously if you called the
.subscribe()
method on aComponentTree
instance before the statechart had been processed the return value would befalse
. This meant that subscribers would have to add checks to do anything against the returned value, since they couldn't depend on the.matches
/.hasTag
/.broadcast
APIs existing.This change fixes that, and ensures that even if the statechart hasn't been walked yet the initial value stored has all the expected APIs, along with a reasonable value for the
tree
property of[]
. There isn't a great fallback value for.state
at this time though.
-
#67
a8aa4ac
Thanks @tivac! - Added.send()
APIThe
.send()
API is a simple passthrough to the interpreter for the root statechart being managed byxstate-component-tree
, and is intended as a convenience function to make it easier to interact with aComponentTree
instance instead of a direct XStateInterpreter
reference.
-
#65
1f93bbc
Thanks @tivac! - Fix for handling the case where a child machine has already been destroyed butxstate-component-tree
hasn't gotten that notice yet.Mostly comes up when you have
{ type : "final" }
states in the child machine and aninvoke.onDone
transition in the parent.
-
#63
d9d3820
Thanks @tivac! - Added observable APIAvailable on the
ComponentTree
instance as.subscribe(callback)
, calls the callback function immediately with the most recent result and then will re-call it each time a build completes.Follows the svelte store contract which isn't strictly compliant with any official observable APIs but is extremely simple and usable.
The
callback
passed to.subscribe(...)
will immediately be called with the most recent result of building the component tree (orfalse
if it hasn't finished yet), and then for each complete tree building run after that thecallback
will be called with a single argument. The arg is anObject
with anull
prototype and the following properties:tree
, nested component structures. This is the same as the first argument to the oldernew ComponentTree(service, callback)
API.state
, an XStateState
instance representing the most recent state of the root statechart.matches(<state>)
,state.matches()
but for every statechart instance including any invoked statecharts.hasTag(<tag>)
,state.hasTag()
but for every statechart instance including any invoked statecharts.broadcast(<event>)
,service.send()
but for every statechart instance including any invoked statecharts. Prefer using this instead of settinginvoke.autoForward
because it'll reduce the amount of junk events sent to invoked children.
All notable changes to this project will be documented in this file. See standard-version for commit guidelines.
4.0.0 (2022-03-16)
- previously the second arg to the callback function had a single
data
property on it representing the lastState
object seen by the top-level machine. Now it hasstate
(same as data was previously), and some bound APIs for interacting with the statechart:.hasTag()
,.broadcast()
, and.matches()
. These are the same APIs available on theComponentTree
instance but made available through the callback args for convenience.
3.5.0 (2022-03-15)
3.4.2 (2022-02-20)
3.4.1 (2021-11-24)
3.4.0 (2021-11-24)
3.3.1 (2020-10-03)
- clear dist when building (068f209)
3.3.0 (2020-10-03)
3.2.0 (2020-08-07)
3.1.2 (2020-08-06)
3.1.1 (2020-08-06)
3.1.0 (2020-07-21)
3.0.0 (2020-03-15)
- caching load methods (d534245)
-
- Only 1 callback per tree change, no matter if it was the deepest child or the root machine.
- Updated
load()
support so it can take either acomponent
or[ component, props ]
as a return and the overallload()
as well as eithercomponent
orprops
will beawait
ed.
2.0.1 (2019-12-14)
- svelte example 2.0 compat (4a7f0da)
2.0.0 (2019-12-13)
- The output format has changed to no longer have an array of machines at the top-level, instead it is just the top-level components representing active states. Invoked machines are no longer part of the top-level array but now inserted into the tree of components based on the location of the component that invoked them.
1.0.0 (2019-10-27)
0.1.0 (2019-10-27)
- invokes removed from output (cc0106f)