redux-sacala 0.3.6 → 0.3.7
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 +49 -1
- package/package.json +20 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Redux Sacala
|
|
2
2
|
|
|
3
|
-
[](https://github.com/monkin/redux-sacala/actions/workflows/test.yml)
|
|
4
4
|
|
|
5
5
|
A library for creating composable Redux blocks with state, actions, and effects.
|
|
6
6
|
|
|
@@ -221,6 +221,54 @@ const store = configureStore({
|
|
|
221
221
|
});
|
|
222
222
|
```
|
|
223
223
|
|
|
224
|
+
### Dependency Injection with [di-sacala](https://github.com/monkin/di-sacala)
|
|
225
|
+
|
|
226
|
+
For larger applications, it is highly recommended to use `di-sacala` to manage and provide dependencies to your effects. It provides a clean way to define and resolve dependencies with full type safety.
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
import { configureStore } from '@reduxjs/toolkit';
|
|
230
|
+
import { ReduxBlock } from "redux-sacala";
|
|
231
|
+
import { DiContainer, DiService } from "di-sacala";
|
|
232
|
+
|
|
233
|
+
// 1. Define your services
|
|
234
|
+
class ApiService implements DiService<"api"> {
|
|
235
|
+
name = "api" as const;
|
|
236
|
+
async fetchUser(id: string) {
|
|
237
|
+
return { id, name: "User " + id };
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
class LoggerService implements DiService<"logger"> {
|
|
242
|
+
name = "logger" as const;
|
|
243
|
+
log(msg: string) {
|
|
244
|
+
console.log(`[LOG]: ${msg}`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
class DispatcherService implements DiService<"dispatch"> {
|
|
249
|
+
name = "dispatch" as const;
|
|
250
|
+
constructor() {
|
|
251
|
+
}
|
|
252
|
+
dispatch(action: Action) {
|
|
253
|
+
// Dispatch action using Redux store
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// 2. Create and configure the container
|
|
258
|
+
const container = new DiContainer()
|
|
259
|
+
.inject(ApiService)
|
|
260
|
+
.inject(LoggerService)
|
|
261
|
+
.inject(DispatcherService);
|
|
262
|
+
|
|
263
|
+
const store = configureStore({
|
|
264
|
+
reducer: rootBlock.reducer,
|
|
265
|
+
middleware: (getDefaultMiddleware) =>
|
|
266
|
+
getDefaultMiddleware().concat(
|
|
267
|
+
ReduxBlock.middleware(rootBlock, container)
|
|
268
|
+
),
|
|
269
|
+
});
|
|
270
|
+
```
|
|
271
|
+
|
|
224
272
|
## License
|
|
225
273
|
|
|
226
274
|
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redux-sacala",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
|
+
"description": "A library for creating composable Redux blocks with state, actions, and effects",
|
|
4
5
|
"license": "MIT",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
@@ -11,10 +12,24 @@
|
|
|
11
12
|
},
|
|
12
13
|
"homepage": "https://github.com/monkin/redux-sacala#readme",
|
|
13
14
|
"type": "module",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"redux",
|
|
17
|
+
"state-management",
|
|
18
|
+
"composition",
|
|
19
|
+
"typescript",
|
|
20
|
+
"toolkit"
|
|
21
|
+
],
|
|
14
22
|
"author": {
|
|
15
23
|
"name": "Andrey Monkin",
|
|
16
24
|
"email": "monkin.andrey@gmail.com"
|
|
17
25
|
},
|
|
26
|
+
"files": [
|
|
27
|
+
"build"
|
|
28
|
+
],
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18"
|
|
32
|
+
},
|
|
18
33
|
"module": "build/redux-sacala.js",
|
|
19
34
|
"main": "build/redux-sacala.cjs",
|
|
20
35
|
"types": "build/redux-sacala.d.ts",
|
|
@@ -32,8 +47,8 @@
|
|
|
32
47
|
"devDependencies": {
|
|
33
48
|
"@eslint/js": "9.39.2",
|
|
34
49
|
"@reduxjs/toolkit": "2.11.2",
|
|
35
|
-
"@types/node": "25.0.
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
50
|
+
"@types/node": "25.0.9",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "8.53.0",
|
|
37
52
|
"@typescript-eslint/parser": "8.53.0",
|
|
38
53
|
"eslint": "9.39.2",
|
|
39
54
|
"eslint-config-prettier": "10.1.8",
|
|
@@ -46,9 +61,10 @@
|
|
|
46
61
|
},
|
|
47
62
|
"scripts": {
|
|
48
63
|
"build": "vite build",
|
|
49
|
-
"prepublishOnly": "npm test && npm run build",
|
|
64
|
+
"prepublishOnly": "npm run lint && npm test && npm run build",
|
|
50
65
|
"test": "vitest run",
|
|
51
66
|
"lint": "eslint .",
|
|
67
|
+
"lint:fix": "eslint . --fix",
|
|
52
68
|
"format": "prettier --write ."
|
|
53
69
|
}
|
|
54
70
|
}
|