@koordinates/xstate-tree 4.1.3 → 4.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,7 +15,7 @@ While xstate-tree manages your application state, it does not have a mechanism f
15
15
 
16
16
  At Koordinates we use xstate-tree for all new UI development. Our desktop application, built on top of [Kart](https://kartproject.org/) our Geospatial version control system, is built entirely with xstate-tree using GraphQL for global state.
17
17
 
18
- A minimal example of a single machine tree (See [CodeSandbox](https://codesandbox.io/s/xstate-tree-b0el6e-forked-4i6txh?file=/src/index.tsx) for slightly expanded multi-machine example):
18
+ A minimal example of a single machine tree:
19
19
 
20
20
  ```tsx
21
21
  import React from "react";
@@ -155,7 +155,7 @@ Slotted machines are determined based on the id of the invoked/spawned machine.
155
155
  `singleSlot` accepts the name of the slot as the first argument and returns an object with a method `getId()` that returns the id of the slot.
156
156
  `multiSlot` accepts the name of the slot and returns an object with a method `getId(id: string)` that returns the id of the slot
157
157
 
158
- You should always use the `getId` methods when invoking/spawning something into a slot. Each slot the machine has must be represented by a call to `singleSlot` or `multiSlot` and stored into an array of slots. These slots must be passed to the `buildView` and `buildXStateTreeMachine` functions.
158
+ You should always use the `getId` methods when invoking/spawning something into a slot. Each slot the machine has must be represented by a call to `singleSlot` or `multiSlot` and stored into an array of slots. These slots must be passed to the `createXStateTreeMachine` function.
159
159
 
160
160
  ### Inter-machine communication
161
161
 
@@ -182,7 +182,7 @@ That adds two events to the system, a no payload event (`{ type: "BASIC" }`) and
182
182
  These events can be added anywhere, either next to a component for component specific events or in a module for events that are for multiple machines. One thing that it is important to keep in mind is that these `declare global` declarations must be loaded by the `.d.ts` files when importing the component, otherwise the events will be missing. Which means
183
183
 
184
184
  1. If they are in their own file, say for a module level declaration, that file will need to be imported somewhere. Somewhere that using a component will trigger the import
185
- 2. If they are tied to a component they need to be in the index.ts file that imports the view/selectors/actions etc and calls `buildXstateTreeMachine`. If they are in the file containing those functions the index.d.ts file will not end up importing them.
185
+ 2. If they are tied to a component they need to be in the index.ts file that imports the view/selectors/actions etc and calls `createXStateTreeMachine`. If they are in the file containing those functions the index.d.ts file will not end up importing them.
186
186
 
187
187
 
188
188
  ### [Storybook](https://storybook.js.org)
package/lib/xstateTree.js CHANGED
@@ -54,7 +54,10 @@ const getViewForInterpreter = memoize((interpreter) => {
54
54
  },
55
55
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
56
  { serializer: cacheKeyForInterpreter });
57
- const getMultiSlotViewForChildren = memoize((parent, slot) => {
57
+ /**
58
+ * @private
59
+ */
60
+ export const getMultiSlotViewForChildren = memoize((parent, slot) => {
58
61
  return React.memo(function MultiSlotView() {
59
62
  const [_, children] = useService(parent);
60
63
  const interpreters = [...children.values()];
@@ -64,10 +67,7 @@ const getMultiSlotViewForChildren = memoize((parent, slot) => {
64
67
  return (React.createElement(XstateTreeMultiSlotView, { childInterpreters: interpretersWeCareAbout }));
65
68
  });
66
69
  }, {
67
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
68
- serializer: ((interpreter, slot) =>
69
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
- `${cacheKeyForInterpreter(interpreter)}-${slot}`),
70
+ serializer: (args) => `${cacheKeyForInterpreter(args[0])}-${args[1]}`,
71
71
  });
72
72
  function useSlots(interpreter, slots) {
73
73
  return useConstant(() => {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@koordinates/xstate-tree",
3
3
  "main": "lib/index.js",
4
4
  "types": "lib/xstate-tree.d.ts",
5
- "version": "4.1.3",
5
+ "version": "4.1.5",
6
6
  "license": "MIT",
7
7
  "description": "Build UIs with Actors using xstate and React",
8
8
  "keywords": [