-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from GuoXiCheng/dev-c
add proxy-pattern md
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/javascript/ecma-script/proxy-and-reflect/proxy-pattern.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# 代理模式 | ||
|
||
## 跟踪属性访问 | ||
|
||
通过捕获`get`、`set` 和 `has` 等操作,可以知道对象属性在何时何处被访问。 | ||
|
||
<<< @/../projects/javascript-sandbox/src/proxy-and-reflect/proxy-pattern.ts#trace-attribute | ||
|
||
## 隐藏属性 | ||
|
||
代理的内部实现对外部实现不可见,因此可以隐藏对象的属性。 | ||
|
||
<<< @/../projects/javascript-sandbox/src/proxy-and-reflect/proxy-pattern.ts#hidden-attribute | ||
|
||
## 属性验证 | ||
|
||
所有的赋值操作都会触发 `set` 捕获器,因此可以根据情况决定允许赋值或拒绝赋值。 | ||
|
||
<<< @/../projects/javascript-sandbox/src/proxy-and-reflect/proxy-pattern.ts#validate-attribute | ||
|
||
## 函数参数验证 | ||
|
||
<<< @/../projects/javascript-sandbox/src/proxy-and-reflect/proxy-pattern.ts#validate-function-parameter | ||
|
||
## 构造函数参数验证 | ||
|
||
<<< @/../projects/javascript-sandbox/src/proxy-and-reflect/proxy-pattern.ts#validate-constructor-parameter | ||
|
||
## 数据绑定 | ||
|
||
<<< @/../projects/javascript-sandbox/src/proxy-and-reflect/proxy-pattern.ts#data-binding | ||
|
||
## 可观察对象 | ||
|
||
<<< @/../projects/javascript-sandbox/src/proxy-and-reflect/proxy-pattern.ts#observable-object |