@fluid-topics/ft-wc-utils 1.2.2 → 1.2.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.
@@ -70,8 +70,8 @@ class FtLitElementRedux extends FtLitElement {
70
70
  (_d = this.reduxConstructor.reduxEventListeners) === null || _d === void 0 ? void 0 : _d.forEach((init, methodName) => {
71
71
  if (typeof this[methodName] === "function" && (!init.store || store.name === init.store)) {
72
72
  const callback = (e) => this[methodName](e);
73
- store.eventBus.addEventListener(init.eventName, callback);
74
- this[internalReduxEventsUnsubscribers].push(() => store.eventBus.removeEventListener(init.eventName, callback));
73
+ store.addEventListener(init.eventName, callback);
74
+ this[internalReduxEventsUnsubscribers].push(() => store.removeEventListener(init.eventName, callback));
75
75
  }
76
76
  });
77
77
  }
@@ -1,18 +1,18 @@
1
1
  import { Action, AnyAction, CaseReducerActions, Dispatch, Observable, Reducer, Slice, SliceCaseReducers, Store, Unsubscribe } from "@reduxjs/toolkit";
2
2
  import { DefaultStateReducer, FtCreateReduxStoreOptions, FtReduxStoreActions } from "./models";
3
3
  import { FtCommandQueue } from "./FtCommandQueue";
4
+ import { WithEventBus } from "../events";
4
5
  declare global {
5
6
  interface Window {
6
7
  ftReduxStores: Record<string, Store<any, any>>;
7
8
  }
8
9
  }
9
- export declare class FtReduxStore<State = any, CR extends SliceCaseReducers<State> = SliceCaseReducers<State>, A extends Action = AnyAction> implements Store<State, FtReduxStoreActions<A>>, Slice<State, CR, string> {
10
+ export declare class FtReduxStore<State = any, CR extends SliceCaseReducers<State> = SliceCaseReducers<State>, A extends Action = AnyAction> extends WithEventBus implements Store<State, FtReduxStoreActions<A>>, Slice<State, CR, string> {
10
11
  private readonly reduxSlice;
11
12
  private readonly reduxStore;
12
13
  readonly isFtReduxStore = true;
13
14
  static get<State = any, CR extends SliceCaseReducers<State> = SliceCaseReducers<State>, A extends Action = AnyAction>(name: string): FtReduxStore<State, CR, A> | undefined;
14
15
  static get<State = any, CR extends SliceCaseReducers<State> = SliceCaseReducers<State>, A extends Action = AnyAction>(options: FtCreateReduxStoreOptions<State, CR>): FtReduxStore<State, CR, A>;
15
- readonly eventBus: EventTarget;
16
16
  readonly commands: FtCommandQueue;
17
17
  private constructor();
18
18
  clear(): void;
@@ -1,10 +1,11 @@
1
1
  import { configureStore, createSlice } from "@reduxjs/toolkit";
2
2
  import { isFtReduxStore } from "./models";
3
3
  import { FtCommandQueue } from "./FtCommandQueue";
4
+ import { WithEventBus } from "../events";
4
5
  if (!window.ftReduxStores) {
5
6
  window.ftReduxStores = {};
6
7
  }
7
- export class FtReduxStore {
8
+ export class FtReduxStore extends WithEventBus {
8
9
  static get(nameOrOptions) {
9
10
  var _a;
10
11
  const name = typeof nameOrOptions === "string" ? nameOrOptions : nameOrOptions.name;
@@ -34,10 +35,10 @@ export class FtReduxStore {
34
35
  return window.ftReduxStores[options.name] = new FtReduxStore(reduxSlice, reduxStore);
35
36
  }
36
37
  constructor(reduxSlice, reduxStore) {
38
+ super();
37
39
  this.reduxSlice = reduxSlice;
38
40
  this.reduxStore = reduxStore;
39
41
  this.isFtReduxStore = true;
40
- this.eventBus = document.createElement("event-bus");
41
42
  this.commands = new FtCommandQueue();
42
43
  // Add proxy to automatically dispatch changes
43
44
  this.actions = new Proxy(this.reduxSlice.actions, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-wc-utils",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Internal web components tools",
5
5
  "author": "Fluid Topics <devtopics@antidot.net>",
6
6
  "license": "ISC",
@@ -15,7 +15,7 @@
15
15
  "dependencies": {
16
16
  "@floating-ui/dom": "1.5.3",
17
17
  "@fluid-topics/design-system-variables": "0.1.5",
18
- "@fluid-topics/public-api": "1.0.77",
18
+ "@fluid-topics/public-api": "1.0.78",
19
19
  "@reduxjs/toolkit": "1.9.5",
20
20
  "@types/mark.js": "8.11.12",
21
21
  "@webcomponents/scoped-custom-element-registry": "0.0.9",
@@ -24,5 +24,5 @@
24
24
  "mark.js": "8.11.1",
25
25
  "moment": "2.29.4"
26
26
  },
27
- "gitHead": "b12fa278dd5bc8a5b9d027ed52dae60b4c821ec4"
27
+ "gitHead": "31c1696257f82afca00cddf81033e8984f665c43"
28
28
  }