@growupsell/commerce 1.0.0-alpha.2 → 1.0.0-alpha.3

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  GrowupsellApiError,
3
3
  createClient
4
- } from "./chunk-AI2CWQ22.js";
4
+ } from "./chunk-BORVKACK.js";
5
5
  import {
6
6
  DEFAULT_LISTING_CRITERIA,
7
7
  LISTING_PAGE_SIZE,
@@ -1092,14 +1092,22 @@ function createCatalogStore(ctx) {
1092
1092
  ctx.events.emit({ type: "error", store: "catalog", action: "load", error });
1093
1093
  return fail(error);
1094
1094
  }
1095
+ function load(options = {}) {
1096
+ if (options.force) return run(["categories", "settings"]);
1097
+ const missing = ["categories", "settings"].filter((part) => !loaded[part]);
1098
+ if (missing.length === 0) return Promise.resolve(ok(void 0));
1099
+ return flight("load", () => run(missing));
1100
+ }
1095
1101
  return {
1096
1102
  ...readOnly(store),
1097
- load(options = {}) {
1098
- if (options.force) return run(["categories", "settings"]);
1099
- const missing = ["categories", "settings"].filter((part) => !loaded[part]);
1100
- if (missing.length === 0) return Promise.resolve(ok(void 0));
1101
- return flight("load", () => run(missing));
1102
- }
1103
+ subscribe(listener) {
1104
+ const unsubscribe = store.subscribe(listener);
1105
+ if (ctx.config.autoLoad && !ctx.isDisposed() && store.getSnapshot().status === "idle") {
1106
+ void load();
1107
+ }
1108
+ return unsubscribe;
1109
+ },
1110
+ load
1103
1111
  };
1104
1112
  }
1105
1113
 
@@ -2977,4 +2985,4 @@ export {
2977
2985
  REFERRAL_TTL_MS,
2978
2986
  createGrowupsellStores
2979
2987
  };
2980
- //# sourceMappingURL=chunk-DHBRITDW.js.map
2988
+ //# sourceMappingURL=chunk-HGCKDE7D.js.map