@view-models/core 1.1.0 → 1.2.0

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 CHANGED
@@ -87,8 +87,8 @@ describe("CounterViewModel", () => {
87
87
 
88
88
  The view models are designed to work with framework-specific adapters. Upcoming adapters include:
89
89
 
90
- - **@view-models/react** - React hooks integration
91
- - **@view-models/preact** - Preact hooks integration
90
+ - [@view-models/react](https://github.com/sunesimonsen/view-models-react) - React hooks integration
91
+ - [@view-models/preact](https://github.com/sunesimonsen/view-models-preact) - Preact hooks integration
92
92
 
93
93
  These adapters will allow you to use the same view model with different frameworks:
94
94
 
@@ -1,7 +1,3 @@
1
- /**
2
- * The base type of view model state.
3
- */
4
- export type State = Readonly<object>;
5
1
  /**
6
2
  * Function that receives the current state and returns the new state.
7
3
  * The updater function should be pure and return a new state object.
@@ -10,7 +6,7 @@ export type State = Readonly<object>;
10
6
  * @param currentState - The current state
11
7
  * @returns The new state
12
8
  */
13
- export type Updater<T extends State> = (currentState: T) => T;
9
+ export type Updater<T> = (currentState: T) => T;
14
10
  /**
15
11
  * Function that gets called when the state changes.
16
12
  *
@@ -24,7 +20,7 @@ export type ViewModelListener<T> = (state: T) => void;
24
20
  * A ViewModel manages state and notifies subscribers when the state changes.
25
21
  * Extend this class to create your own view models with custom business logic.
26
22
  *
27
- * @template T - The state type (must be a readonly object)
23
+ * @template T - The state type
28
24
  *
29
25
  * @example
30
26
  * ```typescript
@@ -47,7 +43,7 @@ export type ViewModelListener<T> = (state: T) => void;
47
43
  * counter.increment(); // Logs: Count: 1
48
44
  * ```
49
45
  */
50
- export declare abstract class ViewModel<T extends State> {
46
+ export declare abstract class ViewModel<T> {
51
47
  private _listeners;
52
48
  /**
53
49
  * Subscribe to state changes.
@@ -1 +1 @@
1
- {"version":3,"file":"ViewModel.d.ts","sourceRoot":"","sources":["../src/ViewModel.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,KA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AC,MAAM,CAAI;IAElB;;;;OAIG;gBACS,YAAY,EAAE,CAAC;IAI3B;;;;;;;;;;;;;;;;OAgBG;IACH,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAQpC;;;;OAIG;IACH,IAAI,KAAK,IAAI,CAAC,CAEb;CACF"}
package/dist/ViewModel.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * A ViewModel manages state and notifies subscribers when the state changes.
5
5
  * Extend this class to create your own view models with custom business logic.
6
6
  *
7
- * @template T - The state type (must be a readonly object)
7
+ * @template T - The state type
8
8
  *
9
9
  * @example
10
10
  * ```typescript
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@view-models/core",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "A lightweight, framework-agnostic library for building reactive view models with TypeScript",
5
5
  "keywords": [
6
6
  "view",
package/src/ViewModel.ts CHANGED
@@ -1,8 +1,3 @@
1
- /**
2
- * The base type of view model state.
3
- */
4
- export type State = Readonly<object>;
5
-
6
1
  /**
7
2
  * Function that receives the current state and returns the new state.
8
3
  * The updater function should be pure and return a new state object.
@@ -11,7 +6,7 @@ export type State = Readonly<object>;
11
6
  * @param currentState - The current state
12
7
  * @returns The new state
13
8
  */
14
- export type Updater<T extends State> = (currentState: T) => T;
9
+ export type Updater<T> = (currentState: T) => T;
15
10
 
16
11
  /**
17
12
  * Function that gets called when the state changes.
@@ -27,7 +22,7 @@ export type ViewModelListener<T> = (state: T) => void;
27
22
  * A ViewModel manages state and notifies subscribers when the state changes.
28
23
  * Extend this class to create your own view models with custom business logic.
29
24
  *
30
- * @template T - The state type (must be a readonly object)
25
+ * @template T - The state type
31
26
  *
32
27
  * @example
33
28
  * ```typescript
@@ -50,7 +45,7 @@ export type ViewModelListener<T> = (state: T) => void;
50
45
  * counter.increment(); // Logs: Count: 1
51
46
  * ```
52
47
  */
53
- export abstract class ViewModel<T extends State> {
48
+ export abstract class ViewModel<T> {
54
49
  private _listeners: Set<ViewModelListener<T>> = new Set();
55
50
 
56
51
  /**