Skip to content

Commit 53c2ff4

Browse files
author
wendy@lastlookeditorial.com
committed
Edited ch06.asciidoc with Atlas code editor
1 parent fd53cca commit 53c2ff4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ch06.asciidoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[[managing-property-access-with-proxies]]
22
== Managing Property Access pass:[<span class="keep-together">with Proxies</span>]
33

4-
Proxies ((("proxies", id="prox6")))are an interesting and powerful feature in ES6 that act as intermediaries between API consumers and objects. In a nutshell, you can use a `Proxy` to determine the desired behavior whenever the properties of an underlying `target` object are accessed. A `handler` object can be used to configure traps for your `Proxy`, which define and restrict how the underlying object is accessed, as we'll see in a bit.
4+
Proxies ((("proxies", id="prox6")))are an interesting and powerful feature in ES6 that act as intermediaries between API consumers and objects. In a nutshell, you can use a `Proxy` to determine the desired behavior whenever the properties of an underlying `target` ((("target")))object are accessed. A `handler` ((("handler")))object can be used to configure traps for your `Proxy`, which define and restrict how the underlying object is accessed, as we'll see in a bit.
55

66
=== Getting Started with Proxy
77

8-
By default, proxies don't do much--in fact they don't do anything. If you don't provide any configuration, your proxy will just work as a pass-through to the `target` object, also known as a "no-op forwarding proxy," meaning that all operations on the proxy object defer to the underlying object.
8+
By ((("proxies", "overview", id="prox6o")))default, proxies don't do much--in fact they don't do anything. If you don't provide any configuration, your proxy will just work as a pass-through to the `target` object, also known as ((("proxies", "no-op forwarding proxy")))a "no-op forwarding proxy," meaning that all operations on the proxy object defer to the underlying object.
99

10-
In the following piece of code, we create a no-op forwarding `Proxy`. You can observe how by assigning a value to `proxy.exposed`, that value is passed onto `target.exposed`. You could think of proxies as the gatekeepers of their underlying objects: they may allow certain operations to go through and prevent others from passing, but they carefully inspect every single interaction with their underlying objects.
10+
In the following piece of code, we create a no-op forwarding `Proxy`. You can observe how by assigning a value to `proxy.exposed`, (((" proxy.exposed")))that value is passed ((("target.exposed")))onto `target.exposed`. You could think of proxies as the gatekeepers of their underlying objects: they may allow certain operations to go through and prevent others from passing, but they carefully inspect every single interaction with their underlying objects.
1111

1212
[source,javascript]
1313
----
@@ -21,7 +21,7 @@ console.log(proxy.somethingElse)
2121
// <- undefined
2222
----
2323

24-
We can make the proxy object a bit more interesting by adding traps. Traps allow you to intercept interactions with `target` in several different ways, as long as those interactions happen through the `proxy` object. For instance, we could use a `get` trap to log every attempt to pull a value out of a property in `target`, or a `set` trap to prevent certain properties from being written to. Let's kick things off by learning more about `get` traps.
24+
We can make the proxy object a bit more interesting by adding traps. Traps allow you to intercept interactions with `target` in several different ways, as long as those interactions happen through the `proxy` object. For instance, we could use a `get` trap to log every attempt to pull a value out of a property in `target`, or a `set` trap to prevent certain properties from being written to. Let's kick things off by learning ((("proxies", "overview", startref="prox6o")))more about `get` traps.
2525

2626
==== Trapping get Accessors
2727

0 commit comments

Comments
 (0)