@mintjamsinc/ichigojs 0.1.60 → 0.1.61

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.
@@ -1,5 +1,13 @@
1
1
  import { LogLevel } from "./util/LogLevel";
2
2
  import { WatcherDictionary } from "./VWatcherOptions";
3
+ /**
4
+ * Definition of a computed property. Either a getter function, or an object exposing both
5
+ * a getter and a setter (writable computed).
6
+ */
7
+ export type VComputedDefinition = (() => unknown) | {
8
+ get: () => unknown;
9
+ set: (value: any) => void;
10
+ };
3
11
  export interface VApplicationOptions {
4
12
  /**
5
13
  * A function that returns the initial data for the application.
@@ -8,10 +16,15 @@ export interface VApplicationOptions {
8
16
  data: () => unknown;
9
17
  /**
10
18
  * A dictionary of computed properties for the application.
11
- * Each key is the name of the computed property, and the value is a function that computes its value.
19
+ * Each key is the name of the computed property, and the value is either:
20
+ * - a getter function that computes its value (read-only computed), or
21
+ * - an object `{ get, set }` that exposes both a getter and a setter (writable computed).
22
+ *
23
+ * Writable computed properties allow expressions like `v-model="myComputed"` to assign through
24
+ * the `set` function, while reads still go through `get`.
12
25
  */
13
26
  computed?: {
14
- [key: string]: () => unknown;
27
+ [key: string]: VComputedDefinition;
15
28
  };
16
29
  /**
17
30
  * A dictionary of methods for the application.
@@ -63,6 +63,14 @@ export declare class VBindings {
63
63
  * @param value The binding value.
64
64
  */
65
65
  setSilent(key: string, value: any): void;
66
+ /**
67
+ * Registers a setter for a writable computed property. When the given key is assigned
68
+ * through the bindings proxy, the setter will be invoked instead of writing directly to
69
+ * the local store.
70
+ * @param key The computed property name.
71
+ * @param setter The setter function to invoke on assignment.
72
+ */
73
+ registerWritableComputed(key: string, setter: (value: any) => void): void;
66
74
  /**
67
75
  * Manually adds an identifier to the set of changed identifiers.
68
76
  * This is useful for computed properties that need to mark themselves as changed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintjamsinc/ichigojs",
3
- "version": "0.1.60",
3
+ "version": "0.1.61",
4
4
  "description": "ichigo.js - Simple and intuitive reactive framework. Lightweight, fast, and user-friendly virtual DOM library",
5
5
  "main": "./dist/ichigo.cjs",
6
6
  "module": "./dist/ichigo.esm.js",