Skip to content

Commit 5f4a588

Browse files
committed
Translate Proxy
1 parent ee36b18 commit 5f4a588

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

README-ja-jp.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ http.onreadystatechange = function () {
476476
http.send(params);
477477
```
478478

479-
ただ、このデータをポストしたいとき、AngularJSの `$http` サービスを使うことができます:
479+
しかし、このデータをポストしたいとき、AngularJSの `$http` サービスを使うことができます:
480480

481481
```JavaScript
482482
$http({
@@ -502,31 +502,31 @@ $http.post('/someUrl', data)
502502

503503
更に高レベルの抽象化は `$http` サービスをもとに構築された `$resource` で行うことができます。このサービスに関しては、 [アクティブ・レコード](#アクティブ・レコード)[プロキシ](#プロキシ) のところでもう少し深く見ていきます。
504504

505-
#### Proxy
505+
#### プロキシ
506506

507-
>A proxy, in its most general form, is a class functioning as an interface to something else. The proxy could interface to anything: a network connection, a large object in memory, a file, or some other resource that is expensive or impossible to duplicate.
507+
>プロキシの最も一般的な形は、何か別のものに対するインターフェイスとしての振る舞うクラスの働きです。プロキシは、通信接続、メモリ上の大きなオブジェクト、ファイル、複製するのが不可能だったりコストが掛かり過ぎるその他のリソースなどいろいろなもののインターフェイスになることができます。
508508
509509
![Proxy](https://rawgit.com/mgechev/angularjs-in-patterns/master/images/proxy.svg "Fig. 9")
510510

511-
We can distinguish three different types of proxy:
511+
プロキシは3つの種類に分けることができます:
512512

513-
- Virtual Proxy
514-
- Remote Proxy
515-
- Protection Proxy
513+
- バーチャル・プロキシ
514+
- リモート・プロキシ
515+
- プロテクション・プロキシ
516516

517-
In this sub-chapter we are going to take a look at AngularJS' implementation of Virtual Proxy.
517+
この副章では、AngularJSのバーじゃる・プロキシの実装を見ていきます。
518518

519-
In the snippet bellow, there is a call to the `get` method of `$resource` instance, called `User`:
519+
下記のスニペットでは、 `User` という名の `$resource` インスタンスの `get` メソッドを呼んでいます:
520520

521521
```JavaScript
522522
var User = $resource('/users/:id'),
523523
user = User.get({ id: 42 });
524524
console.log(user); //{}
525525
```
526526

527-
`console.log` would outputs an empty object. Since the AJAX request, which happens behind the scene, when `User.get` is invoked, is asynchronous, we don't have the actual user when `console.log` is called. Just after `User.get` makes the GET request it returns an empty object and keeps reference to it. We can think of this object as virtual proxy (a simple placeholder), which would be populated with the actual data once the client receives response by the server.
527+
`console.log` は空のオブジェクトを出力します。 AJAXリクエストは、 `User.get` が呼ばれた時点で非同期で処理されていて、 `console.log` が呼ばれた時点ではまだ実際のユーザが準備されていないのです。 `User.get` はGETリクエストをし、空のオブジェクトを返しますが、参照は持ち続けています。このオブジェクトをバーチャル・プロキシ(単に、プレースホルダーとも)考えることができます。クライアントがサーバからレスポンスを受け取ると実際のデータが格納されます。
528528

529-
How does this works with AngularJS? Well, lets consider the following snippet:
529+
これはAngularJSでどのように使われるのでしょうか? 次のスニペットを考えてみましょう:
530530

531531
```JavaScript
532532
function MainCtrl($scope, $resource) {
@@ -538,7 +538,8 @@ function MainCtrl($scope, $resource) {
538538
```html
539539
<span ng-bind="user.name"></span>
540540
```
541-
Initially when the snippet above executes, the property `user` of the `$scope` object will be with value an empty object (`{}`), which means that `user.name` will be undefined and nothing will be rendered. Internally AngularJS will keep reference to this empty object. Once the server returns response for the get request, AngularJS will populate the object with the data, received from the server. During the next `$digest` loop AngularJS will detect change in `$scope.user`, which will lead to update of the view.
541+
542+
上記のスニペットが事項された直後、 `$scope``user` プロパティは空のオブジェクト( `{}` )になります。 `user.name` はundefinedとなり何もレンダリングされません。内部ではAngularJSはこの空のオブジェクトに参照を保っています。サーバがGETリクエストのレスポンスを返すと、AngularJSはサーバから受け取ったデータをオブジェクトに格納します。次の `$digest` ループでAngularJSは `$scope.user` の変更を検知し、ビューの更新に移ります。
542543

543544
#### Active Record
544545

0 commit comments

Comments
 (0)