@doeixd/machine 1.2.1 → 1.3.0

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.
@@ -1715,12 +1715,14 @@ function state(context, transitions) {
1715
1715
  // src/index.ts
1716
1716
  function createMachine(context, fnsOrFactory) {
1717
1717
  if (typeof fnsOrFactory === "function") {
1718
+ let self;
1718
1719
  let transitions2;
1719
1720
  const transition = (newContext) => {
1720
- return createMachine(newContext, transitions2);
1721
+ return newContext === context ? self : createMachine(newContext, transitions2);
1721
1722
  };
1722
1723
  transitions2 = fnsOrFactory(transition);
1723
- return attachTransitions(Object.assign({ context }, transitions2), transitions2);
1724
+ self = attachTransitions(Object.assign({ context }, transitions2), transitions2);
1725
+ return self;
1724
1726
  }
1725
1727
  const stored = getStoredTransitions(fnsOrFactory);
1726
1728
  const transitions = stored != null ? stored : "context" in fnsOrFactory ? snapshotOwnTransitions(fnsOrFactory) : fnsOrFactory;