@inglorious/react-store 4.0.0 → 5.0.1

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.jsx +3 -39
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/react-store",
3
- "version": "4.0.0",
3
+ "version": "5.0.1",
4
4
  "description": "Official React bindings for @inglorious/store. Provides hooks and a Provider to connect your React components to the store.",
5
5
  "author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": "^19.2.0",
43
- "@inglorious/store": "5.5.0"
43
+ "@inglorious/store": "6.0.1"
44
44
  },
45
45
  "devDependencies": {
46
46
  "prettier": "^3.6.2",
package/src/index.jsx CHANGED
@@ -1,49 +1,13 @@
1
- import { sendAction } from "@inglorious/store/client/dev-tools"
2
- import { useCallback } from "react"
3
1
  import { Provider, useSelector } from "react-redux"
4
2
 
5
- const DEFAULT_CONFIG = { mode: "eager" }
6
- const ONE_SECOND = 1000
7
- const DEFAULT_FPS = 20
8
-
9
- export function createReactStore(store, config = DEFAULT_CONFIG) {
10
- if (config.mode === "batched") {
11
- loop(store, config)
12
- }
13
-
14
- return { Provider: StoreProvider, useSelector, useNotify }
15
-
3
+ export function createReactStore(store) {
16
4
  function StoreProvider({ children }) {
17
5
  return <Provider store={store}>{children}</Provider>
18
6
  }
19
7
 
20
8
  function useNotify() {
21
- return useCallback((type, payload) => {
22
- store.notify(type, payload)
23
-
24
- if (config.mode === "eager") {
25
- sendAction({ type, payload }, store.getState())
26
- }
27
- }, [])
9
+ return store._api.notify
28
10
  }
29
- }
30
-
31
- function loop(store, config) {
32
- const fps = config.fps ?? DEFAULT_FPS
33
11
 
34
- setInterval(() => {
35
- const processedEvents = store.update()
36
- const skippedEvents = config.skippedEvents ?? []
37
-
38
- const eventsToLog = processedEvents.filter(
39
- ({ type }) => !skippedEvents.includes(type),
40
- )
41
- if (eventsToLog.length) {
42
- const action = {
43
- type: eventsToLog.map(({ type }) => type).join("|"),
44
- payload: eventsToLog,
45
- }
46
- sendAction(action, store.getState())
47
- }
48
- }, ONE_SECOND / fps)
12
+ return { Provider: StoreProvider, useSelector, useNotify }
49
13
  }