@view-models/core 1.0.0 → 1.1.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
@@ -2,6 +2,8 @@
2
2
 
3
3
  A lightweight, framework-agnostic library for building reactive view models with TypeScript. Separate your business logic from your UI framework with a simple, testable pattern.
4
4
 
5
+ ![View models banner](./view-models.png)
6
+
5
7
  ## Why View Models?
6
8
 
7
9
  - **Framework Agnostic**: Write your logic once, use it with React, Preact, or any other framework
@@ -200,9 +202,10 @@ class AppViewModel {
200
202
  }
201
203
  ```
202
204
 
203
- ### Handle Side Effects
205
+ ### Asynchronous actions
204
206
 
205
- Keep your update logic pure, but expose methods for side effects:
207
+ While the update logic is pure, you can use methods to execute asynchronous
208
+ actions:
206
209
 
207
210
  ```typescript
208
211
  class TodosViewModel extends ViewModel<TodosState> {
@@ -1,4 +1,7 @@
1
- type State = Readonly<object>;
1
+ /**
2
+ * The base type of view model state.
3
+ */
4
+ export type State = Readonly<object>;
2
5
  /**
3
6
  * Function that receives the current state and returns the new state.
4
7
  * The updater function should be pure and return a new state object.
@@ -97,5 +100,4 @@ export declare abstract class ViewModel<T extends State> {
97
100
  */
98
101
  get state(): T;
99
102
  }
100
- export {};
101
103
  //# sourceMappingURL=ViewModel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ViewModel.d.ts","sourceRoot":"","sources":["../src/ViewModel.ts"],"names":[],"mappings":"AAAA,KAAK,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;AAE9B;;;;;;;GAOG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,8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package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@view-models/core",
3
- "version": "1.0.0",
3
+ "version": "1.1.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,4 +1,7 @@
1
- type State = Readonly<object>;
1
+ /**
2
+ * The base type of view model state.
3
+ */
4
+ export type State = Readonly<object>;
2
5
 
3
6
  /**
4
7
  * Function that receives the current state and returns the new state.