@webqit/observer 3.8.12 → 3.8.13
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 +17 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -96,7 +96,7 @@ This limitation in the language has long created a **blindspot** — and a **wea
|
|
|
96
96
|
|
|
97
97
|
By enabling observability at the object/array level, the Observer API effectively solves reactivity for a mutable world. **The Result** is *mutation-based reactivity* as a first-class concept in JavaScript. Consequently:
|
|
98
98
|
|
|
99
|
-
+ you are able to weild *the
|
|
99
|
+
+ you are able to weild *the full power of mutability* in programming to your advantage
|
|
100
100
|
+ you are able to make sense of a mutable world — and integrate with it — rather than stand at odds with it
|
|
101
101
|
|
|
102
102
|
## Quick Start
|
|
@@ -157,7 +157,8 @@ Observer.set(items, 0, 'grape');
|
|
|
157
157
|
Observer.set(items, 2, 'orange');
|
|
158
158
|
|
|
159
159
|
// Reactive method calls
|
|
160
|
-
Observer.apply(items.push, items, ['new item']);
|
|
160
|
+
Observer.apply(items.push, items, ['new item']);
|
|
161
|
+
Observer.proxy(state.items).push('new item')
|
|
161
162
|
```
|
|
162
163
|
|
|
163
164
|
### Intercepting Operations
|
|
@@ -324,7 +325,7 @@ parentController.abort();
|
|
|
324
325
|
#### Parity Table
|
|
325
326
|
|
|
326
327
|
| | Observer API | Object.observe() (Deprecated) |
|
|
327
|
-
|
|
328
|
+
|:-------------|:--------------|:-------------------------------|
|
|
328
329
|
| **Signature** | `.observe(target, callback, options?)` | `.observe(target, callback, acceptList?)` |
|
|
329
330
|
| **Return Value** | `AbortController` (lifecycle management) | `undefined` (no lifecycle management) |
|
|
330
331
|
| **Additional Features** | AbortSignal integration, path watching, batch/atomic operations, synchronous event model, etc. | Basic object observation, asynchronous event model (deprecated) |
|
|
@@ -424,7 +425,7 @@ Observer.intercept(obj, 'get', (operation, previous, next) => {
|
|
|
424
425
|
#### Parity Table
|
|
425
426
|
|
|
426
427
|
| | Observer API | Proxy Traps |
|
|
427
|
-
|
|
428
|
+
|:-------------|:--------------|:-------------|
|
|
428
429
|
| **Signature** | `.intercept(target, operation, handler, options?)`<br>`.intercept(target, { [operation]: handler[, ...]}, options?)` | `new Proxy(target, { [operation]: handler[, ...] })` |
|
|
429
430
|
| **Return Value** | `undefined` (registration) | `Proxy` (wrapped object) |
|
|
430
431
|
| **Additional Features** | Traps pipeline, composable interceptors | Single trap per operation, no composability |
|
|
@@ -475,7 +476,7 @@ Observer.set(obj, Observer.path('user', 'profile', 'name'), 'Alice');
|
|
|
475
476
|
#### Parity Table
|
|
476
477
|
|
|
477
478
|
| | Observer API | Reflect API |
|
|
478
|
-
|
|
479
|
+
|:-------------|:--------------|:-------------|
|
|
479
480
|
| **Signature** | `.set(target, key, value, options?)` | `.set(target, key, value)` |
|
|
480
481
|
| **Return Value** | `boolean` (success) | `boolean` (success) |
|
|
481
482
|
| **Additional Features** | Triggers observers, interceptable | Standard property setting |
|
|
@@ -509,7 +510,7 @@ Observer.get(obj, 'fullName'); // "John Doe" (computed on-the-fly)
|
|
|
509
510
|
#### Parity Table
|
|
510
511
|
|
|
511
512
|
| | Observer API | Reflect API |
|
|
512
|
-
|
|
513
|
+
|:-------------|:--------------|:-------------|
|
|
513
514
|
| **Signature** | `.get(target, key, options?)` | `.get(target, key)` |
|
|
514
515
|
| **Return Value** | `any` (property value) | `any` (property value) |
|
|
515
516
|
| **Additional Features** | Interceptable for computed values | Standard property access |
|
|
@@ -543,7 +544,7 @@ Observer.has(obj, 'password'); // false (hidden from checks)
|
|
|
543
544
|
#### Parity Table
|
|
544
545
|
|
|
545
546
|
| | Observer API | Reflect API |
|
|
546
|
-
|
|
547
|
+
|:-------------|:--------------|:-------------|
|
|
547
548
|
| **Signature** | `.has(target, key, options?)` | `.has(target, key)` |
|
|
548
549
|
| **Return Value** | `boolean` (exists) | `boolean` (exists) |
|
|
549
550
|
| **Additional Features** | Interceptable for property hiding | Standard property existence check |
|
|
@@ -574,7 +575,7 @@ Observer.ownKeys(obj); // ['name', 'email'] (password filtered out)
|
|
|
574
575
|
#### Parity Table
|
|
575
576
|
|
|
576
577
|
| | Observer API | Reflect API | Object API |
|
|
577
|
-
|
|
578
|
+
|:-------------|:--------------|:-------------|:-------------|
|
|
578
579
|
| **Signature** | `.ownKeys(target, options?)` | `.ownKeys(target)` | `.keys(obj)` |
|
|
579
580
|
| **Return Value** | `string[]` (keys) | `string[]` (keys) | `string[]` (keys) |
|
|
580
581
|
| **Additional Features** | Interceptable for key filtering | Standard key enumeration | Standard key enumeration |
|
|
@@ -592,7 +593,7 @@ Observer.deleteProperty(arr, 0);
|
|
|
592
593
|
#### Parity Table
|
|
593
594
|
|
|
594
595
|
| | Observer API | Reflect API |
|
|
595
|
-
|
|
596
|
+
|:-------------|:--------------|:-------------|
|
|
596
597
|
| **Signature** | `.deleteProperty(target, key, options?)` | `.deleteProperty(target, key)` |
|
|
597
598
|
| **Return Value** | `boolean` (success) | `boolean` (success) |
|
|
598
599
|
| **Additional Features** | Triggers observers, interceptable | Standard property deletion |
|
|
@@ -608,7 +609,7 @@ Observer.deleteProperties(obj, ['oldProp1', 'oldProp2', 'tempProp']);
|
|
|
608
609
|
#### Parity Table
|
|
609
610
|
|
|
610
611
|
| | Observer API | No Direct Equivalent |
|
|
611
|
-
|
|
612
|
+
|:-------------|:--------------|:---------------------|
|
|
612
613
|
| **Signature** | `.deleteProperties(target, keys, options?)` | No batch delete in standard APIs |
|
|
613
614
|
| **Return Value** | `boolean[]` (success array) | N/A |
|
|
614
615
|
| **Additional Features** | Triggers observers, interceptable | N/A |
|
|
@@ -628,7 +629,7 @@ Observer.defineProperty(obj, 'computed', {
|
|
|
628
629
|
#### Parity Table
|
|
629
630
|
|
|
630
631
|
| | Observer API | Reflect API | Object API |
|
|
631
|
-
|
|
632
|
+
|:-------------|:--------------|:-------------|:-------------|
|
|
632
633
|
| **Signature** | `.defineProperty(target, key, descriptor, options?)` | `.defineProperty(target, key, descriptor)` | `.defineProperty(obj, key, descriptor)` |
|
|
633
634
|
| **Return Value** | `boolean` (success) | `boolean` (success) | `object` (modified object) |
|
|
634
635
|
| **Additional Features** | Triggers observers, interceptable | Standard property definition | Standard property definition |
|
|
@@ -648,7 +649,7 @@ Observer.defineProperties(obj, {
|
|
|
648
649
|
#### Parity Table
|
|
649
650
|
|
|
650
651
|
| | Observer API | Object API |
|
|
651
|
-
|
|
652
|
+
|:-------------|:--------------|:-------------|
|
|
652
653
|
| **Signature** | `.defineProperties(target, descriptors, options?)` | `.defineProperties(obj, descriptors)` |
|
|
653
654
|
| **Return Value** | `boolean` (success) | `object` (modified object) |
|
|
654
655
|
| **Additional Features** | Triggers observers, interceptable | Standard property definition |
|
|
@@ -676,7 +677,7 @@ obj.email = 'alice@example.com';
|
|
|
676
677
|
#### Parity Table
|
|
677
678
|
|
|
678
679
|
| | Observer API | No Direct Equivalent |
|
|
679
|
-
|
|
680
|
+
|:-------------|:--------------|:---------------------|
|
|
680
681
|
| **Signature** | `.accessorize(target, properties?, options?)` | No direct equivalent in standard APIs |
|
|
681
682
|
| **Return Value** | `undefined` (modification) | N/A |
|
|
682
683
|
| **Additional Features** | Makes properties reactive for direct assignment | N/A |
|
|
@@ -696,7 +697,7 @@ Observer.unaccessorize(obj);
|
|
|
696
697
|
#### Parity Table
|
|
697
698
|
|
|
698
699
|
| | Observer API | No Direct Equivalent |
|
|
699
|
-
|
|
700
|
+
|:-------------|:--------------|:---------------------|
|
|
700
701
|
| **Signature** | `.unaccessorize(target, properties?, options?)` | No direct equivalent in standard APIs |
|
|
701
702
|
| **Return Value** | `undefined` (modification) | N/A |
|
|
702
703
|
| **Additional Features** | Restores accessorized properties to normal state | N/A |
|
|
@@ -866,7 +867,7 @@ const $obj = Observer.proxy(obj, {}, (traps) => {
|
|
|
866
867
|
#### Parity Table
|
|
867
868
|
|
|
868
869
|
| | Observer API | Proxy API |
|
|
869
|
-
|
|
870
|
+
|:-------------|:--------------|:-----------|
|
|
870
871
|
| **Signature** | `.proxy(target, options?)` | `new Proxy(target, handlers)` |
|
|
871
872
|
| **Return Value** | `Proxy` (reactive proxy) | `Proxy` (standard proxy) |
|
|
872
873
|
| **Additional Features** | Built-in reactivity, membrane, chainable | Manual trap implementation required |
|
|
@@ -883,7 +884,7 @@ const original = Observer.unproxy($obj); // Returns original obj
|
|
|
883
884
|
#### Parity Table
|
|
884
885
|
|
|
885
886
|
| | Observer API | No Direct Equivalent |
|
|
886
|
-
|
|
887
|
+
|:-------------|:--------------|:---------------------|
|
|
887
888
|
| **Signature** | `.unproxy(target)` | No direct equivalent in standard APIs |
|
|
888
889
|
| **Return Value** | `object` (original object) | N/A |
|
|
889
890
|
| **Additional Features** | Extracts original object from Observer proxy | N/A |
|