fluxie 1.3.0 → 1.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.3.1](https://github.com/LesFabricants/Fluxie/compare/v1.3.0...v1.3.1) (2026-03-18)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * check for indexedDB support ([e74a100](https://github.com/LesFabricants/Fluxie/commit/e74a10010f46e11c447fa7472a5f05ebd9a1467f))
9
+ * check for indexedDB support ([2b3f944](https://github.com/LesFabricants/Fluxie/commit/2b3f944a6b93ec891e89847084b2552406cf49d8))
10
+
3
11
  ## [1.3.0](https://github.com/LesFabricants/Fluxie/compare/v1.2.1...v1.3.0) (2024-06-04)
4
12
 
5
13
 
package/README.md CHANGED
@@ -2,9 +2,6 @@
2
2
 
3
3
  Super small helper class meant to greatly simplify the creation of a flux architecture using angular service, complete with redux devtool and caching support
4
4
 
5
- **Warning**
6
- **Requires 2Kb of available space, make sure you have the space before installing !**
7
-
8
5
  ## Installation
9
6
 
10
7
  The latest version supports signals, and thus requires a version of angular 16 minimum, other versions can use the lts release that removes signals support
@@ -190,4 +187,27 @@ if (!environment.production) {
190
187
  }
191
188
  ```
192
189
 
190
+ ## Testing
191
+
192
+ In order to test a component or service using a store, you can simply setup a default state before all your tests
193
+
194
+ ```ts
195
+ beforeEach(async () => {
196
+ await TestBed.configureTestingModule({
197
+ imports: [User],
198
+ providers: [
199
+ UsersService,
200
+ UsersStore,
201
+ UsersQuery,
202
+ ],
203
+ }).compileComponents();
204
+
205
+ const userStore = TestBed.inject(UsersStore);
206
+ userStore.setState('[Test] setup store state', (defaultState) => ({
207
+ ...defaultState,
208
+ ...TEST_STATE_HERE,
209
+ }));
210
+ });
211
+ ```
212
+
193
213
  Your redux devtool menu will now show all your store actions, the option `storeName` will be the store instance name there (defaults to the class name if not provided), and every service extending the `Store` class will be its own instance in the dropdown at the top.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{BehaviorSubject as p}from"rxjs";var r={},o=!1;function h(){o=!0}function l(i,t,s){if(!d())return!1;let e=window?.__REDUX_DEVTOOLS_EXTENSION__.connect({name:i});e.init(s),e.subscribe(n=>{n.type==="DISPATCH"&&n.payload.type==="JUMP_TO_ACTION"&&t.next(JSON.parse(n.state))}),r[i]=e}function c(i,t,s){if(!d())return!1;if(!o)throw new Error("Devtools not enabled, please call enableReduxDevtools() in app.module.ts");r[i].send(t,s)}function d(){return window?.__REDUX_DEVTOOLS_EXTENSION__!==void 0}import{toSignal as u}from"@angular/core/rxjs-interop";var a=class{options;state;select$;select;db;constructor(t,s){if(this.options={...s,storeName:s?.storeName??this.constructor.name},this.state=new p(t),this.select$=this.state.asObservable(),this.select=u(this.state),s?.cache){let e=globalThis.indexedDB.open("__FLUXIE_STORE",1);e.onerror=()=>{console.error(`IndexedDB error: ${e.error}`)},e.onsuccess=()=>{this.db=e.result,this.initializeFromIndexedDB()},e.onupgradeneeded=n=>{this.db=e.result,n.newVersion===1&&this.db.createObjectStore("cachedData")}}o&&l(this.options.storeName,this.state,this.state.getValue())}setState(t,s){let e=s(this.state.getValue());this.state.next(e),this.options?.cache&&this.sendToIndexedDB(this.state.getValue()),o&&c(this.options.storeName,t,e)}async initializeFromIndexedDB(){let t=this.db.transaction("cachedData").objectStore("cachedData").get(this.options.storeName);t.onsuccess=()=>{let s=t.result;s?this.state.next(s):this.sendToIndexedDB(this.state.getValue())}}async sendToIndexedDB(t){this.db.transaction("cachedData","readwrite").objectStore("cachedData").put(t,this.options.storeName)}};export{a as Store,h as enableReduxDevtools,o as isDevtoolEnabled};
1
+ import{BehaviorSubject as p}from"rxjs";var r={},o=!1;function h(){o=!0}function l(i,t,s){if(!d())return!1;let e=window?.__REDUX_DEVTOOLS_EXTENSION__.connect({name:i});e.init(s),e.subscribe(n=>{n.type==="DISPATCH"&&n.payload.type==="JUMP_TO_ACTION"&&t.next(JSON.parse(n.state))}),r[i]=e}function c(i,t,s){if(!d())return!1;if(!o)throw new Error("Devtools not enabled, please call enableReduxDevtools() in app.module.ts");r[i].send(t,s)}function d(){return window?.__REDUX_DEVTOOLS_EXTENSION__!==void 0}import{toSignal as u}from"@angular/core/rxjs-interop";var a=class{options;state;select$;select;db;constructor(t,s){if(this.options={...s,storeName:s?.storeName??this.constructor.name},this.state=new p(t),this.select$=this.state.asObservable(),this.select=u(this.state),s?.cache)if(globalThis.indexedDB){let e=globalThis.indexedDB.open("__FLUXIE_STORE",1);e.onerror=()=>{console.error(`IndexedDB error: ${e.error}`)},e.onsuccess=()=>{this.db=e.result,this.initializeFromIndexedDB()},e.onupgradeneeded=n=>{this.db=e.result,n.newVersion===1&&this.db.createObjectStore("cachedData")}}else console.warn("fluxie caching is not supported in this environment, disabling"),this.options.cache=!1;o&&l(this.options.storeName,this.state,this.state.getValue())}setState(t,s){let e=s(this.state.getValue());this.state.next(e),this.options?.cache&&this.sendToIndexedDB(this.state.getValue()),o&&c(this.options.storeName,t,e)}async initializeFromIndexedDB(){let t=this.db.transaction("cachedData").objectStore("cachedData").get(this.options.storeName);t.onsuccess=()=>{let s=t.result;s?this.state.next(s):this.sendToIndexedDB(this.state.getValue())}}async sendToIndexedDB(t){this.db.transaction("cachedData","readwrite").objectStore("cachedData").put(t,this.options.storeName)}};export{a as Store,h as enableReduxDevtools,o as isDevtoolEnabled};
package/dist/main.js ADDED
@@ -0,0 +1 @@
1
+ import{BehaviorSubject as p}from"rxjs";var r={},o=!1;function h(){o=!0}function l(i,t,s){if(!d())return!1;let e=window?.__REDUX_DEVTOOLS_EXTENSION__.connect({name:i});e.init(s),e.subscribe(n=>{n.type==="DISPATCH"&&n.payload.type==="JUMP_TO_ACTION"&&t.next(JSON.parse(n.state))}),r[i]=e}function c(i,t,s){if(!d())return!1;if(!o)throw new Error("Devtools not enabled, please call enableReduxDevtools() in app.module.ts");r[i].send(t,s)}function d(){return window?.__REDUX_DEVTOOLS_EXTENSION__!==void 0}import{toSignal as u}from"@angular/core/rxjs-interop";var a=class{options;state;select$;select;db;constructor(t,s){if(this.options={...s,storeName:s?.storeName??this.constructor.name},this.state=new p(t),this.select$=this.state.asObservable(),this.select=u(this.state),s?.cache){let e=globalThis.indexedDB.open("store",1);e.onerror=()=>{console.error(`IndexedDB error: ${e.error}`)},e.onsuccess=()=>{this.db=e.result,this.initializeFromIndexedDB()},e.onupgradeneeded=n=>{this.db=e.result,n.newVersion===1&&this.db.createObjectStore("cachedData"),this.initializeFromIndexedDB()}}o&&l(this.options.storeName,this.state,this.state.getValue())}setState(t,s){let e=s(this.state.getValue());this.state.next(e),this.options?.cache&&this.sendToIndexedDB(this.state.getValue()),o&&c(this.options.storeName,t,e)}async initializeFromIndexedDB(){let t=this.db.transaction("cachedData").objectStore("cachedData").get(this.options.storeName);t.onsuccess=()=>{let s=t.result;s?this.state.next(s):this.sendToIndexedDB(this.state.getValue())}}async sendToIndexedDB(t){this.db.transaction("cachedData","readwrite").objectStore("cachedData").put(t,this.options.storeName)}};export{a as Store,h as enableReduxDevtools,o as isDevtoolEnabled};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "fluxie",
3
3
  "description": "Small helper class to easily implement Flux architecture using angular service, complete with redux devtool and caching support",
4
4
  "authors": "Anthony Lenglet",
5
- "version": "1.3.0",
5
+ "version": "1.3.1",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "author": {