@webqit/observer 3.8.10 → 3.8.12
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 +8 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
Observe and intercept operations on arbitrary JavaScript objects and arrays using a utility-first, general-purpose reactivity API!
|
|
14
|
+
Observe and intercept operations on arbitrary JavaScript objects and arrays using a utility-first, general-purpose reactivity API!
|
|
15
|
+
|
|
16
|
+
This API re-explores the unique design of the retired [Object.observe()](https://web.dev/es7-observe/) API and unifies that with the rest of JavaScript's metaprogramming APIs: `Proxies`, `Reflect`, `Object`!
|
|
15
17
|
|
|
16
18
|
The Observer API comes as one little API for all things _object observability_. (Only `~5.8KiB min|zip`)
|
|
17
19
|
|
|
@@ -80,26 +82,22 @@ This limitation in the language has long created a **blindspot** — and a **wea
|
|
|
80
82
|
state = { ...state, count: 8 };
|
|
81
83
|
```
|
|
82
84
|
|
|
83
|
-
```js
|
|
85
|
+
```js
|
|
84
86
|
state = { ...state, items: [...state.items, 'new item 1'] };
|
|
85
87
|
state = { ...state, items: [...state.items, 'new item 2'] };
|
|
86
88
|
state = { ...state, items: [...state.items, 'new item 3'] };
|
|
87
89
|
```
|
|
88
90
|
|
|
89
|
-
> Because this is generally hard to follow, frameworks typically enforce immutability
|
|
91
|
+
> Because this is generally hard to follow, frameworks typically enforce immutability using strong design constraints. Outside of a framework, you get standalone *immutability* libraries (like Immer, or Immutable.js back in the day) that as well try to simulate an immutable world, where data is never changed, only replaced.
|
|
90
92
|
|
|
91
93
|
+ mutation gets a bad rap
|
|
92
94
|
|
|
93
95
|
**Using the Observer API:**
|
|
94
96
|
|
|
95
|
-
By enabling observability at the object/array level, the Observer API effectively solves reactivity for a mutable world. Consequently:
|
|
96
|
-
|
|
97
|
-
+ you are able to weild *the sheer power of mutability* in programming to your advantage — and unappologetically
|
|
98
|
-
+ you are able to make sense of a mutable world — and integrate with it — rather than stand at odds with it.
|
|
99
|
-
|
|
100
|
-
The Observer API collapses layers of complexity that reactive frameworks have built around immutability, bringing you back to the simplicity and power of direct mutation—and this time, with full observability.
|
|
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:
|
|
101
98
|
|
|
102
|
-
|
|
99
|
+
+ you are able to weild *the sheer power of mutability* in programming to your advantage
|
|
100
|
+
+ you are able to make sense of a mutable world — and integrate with it — rather than stand at odds with it
|
|
103
101
|
|
|
104
102
|
## Quick Start
|
|
105
103
|
|