You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `create` method is the starting point for using Observable Slim. It is invoked to create a new ES6 Proxy whose changes we can observe. The `create` method accepts three parameters:
34
+
The `create` method is the starting point for using Observable Slim. It is invoked to create a new ES6 `Proxy` whose changes we can observe. The `create` method accepts three parameters:
36
35
37
-
1.`target` - Object, required, plain JavaScript object that we want to observe for changes.
38
-
2.`domDelay` - Boolean, required, if true, then Observable Slim will batch up observed changes to `target` on a 10ms delay (via `setTimeout`). If false, then `observer` will be immediately invoked after each individual change made to `target`. It is helpful to set `domDelay` to `true` when your `observer` function makes DOM manipulations (fewer DOM redraws means better performance).
39
-
3.`observer` - Function, optional, will be invoked when a change is made to the proxy of `target`. When invoked, the `observer` function is passed a single argument -- an array detailing each change that has been made (see below).
36
+
1.`target` (`object`, *required*): plain object that we want to observe for changes.
37
+
2.`domDelay` (`boolean|number`, *required*): if `true`, then the observed changes to `target` will be batched up on a 10ms delay (via `setTimeout()`). If `false`, then the `observer` function will be immediately invoked after each individual change made to `target`. It is helpful to set `domDelay` to `true` when your `observer` function makes DOM manipulations (fewer DOM redraws means better performance). If a number greater than zero, then it defines the DOM delay in milliseconds.
38
+
3.`observer` (`function(ObservableSlimChange[])`, *optional*): function that will be invoked when a change is made to the proxy of `target`. When invoked, this function is passed a single argument: an array of `ObservableSlimChange` detailing each change that has been made. The `ObservableSlimChange` object structure is like below:
- `currentPath` (`string`, *required*): property path with the dot notation (e.g. `foo.0.bar`).
42
+
- `jsonPointer` (`string`, *required*): property path with the JSON pointer syntax (e.g. `/foo/0/bar`). See [](https://datatracker.ietf.org/doc/html/rfc6901).
43
+
- `target` (`object`, *required*): target object.
44
+
- `proxy` (`Proxy`, *required*): proxy of the target object.
45
+
- `newValue` (`*`, *required*): new value of the property.
46
+
- `previousValue` (`*`, *optional*): previous value of the property.
40
47
41
-
The `create` method will return a standard ES6 Proxy.
48
+
The `create` method will return a standard ES6 `Proxy`.
For full functionality, Observable Slim requires [ES6 Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy).
236
+
For full functionality, Observable Slim requires [ES6 `Proxy`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy).
230
237
231
-
As of August 2017, ES6 Proxy is supported by Chrome 49+, Edge 12+, Firefox 18+, Opera 36+ and Safari 10+. Internet Explorer does not support ES6 Proxy.
238
+
As of August 2017, ES6 `Proxy` is supported by Chrome 49+, Edge 12+, Firefox 18+, Opera 36+ and Safari 10+. Internet Explorer does not support ES6 `Proxy`.
232
239
233
240
### ES5 Proxy polyfill (IE11 support) ###
234
241
@@ -238,7 +245,7 @@ The forked version of the Proxy polyfill (contained within this repo) differs fr
238
245
239
246
#### Limitations ####
240
247
241
-
Because the Proxy polyfill does not (and will never) fully emulate native ES6 Proxy, there are certain use cases that will not work when using Observable Slim with the Proxy polyfill:
248
+
Because the Proxy polyfill does not (and will never) fully emulate native ES6 `Proxy`, there are certain use cases that will not work when using Observable Slim with the Proxy polyfill:
242
249
243
250
1. Object properties must be known at creation time. New properties cannot be added later.
0 commit comments