The Wayback Machine - https://web.archive.org/web/20201029210531/https://github.com/javascript-tutorial/vi.javascript.info/pull/79
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduction: callbacks #79

Open
wants to merge 1 commit into
base: master
from

Conversation

@quocthangit247
Copy link

@quocthangit247 quocthangit247 commented May 10, 2020

No description provided.

@javascript-translate-bot javascript-translate-bot requested a review from javascript-tutorial/translate-vi May 10, 2020
@javascript-translate-bot
Copy link

@javascript-translate-bot javascript-translate-bot commented May 10, 2020

Error: the article already has PR number in the Progress Issue #1, it's 76 ⁉️

@quocthangit247
Copy link
Author

@quocthangit247 quocthangit247 commented May 10, 2020

Error: the article already has PR number in the Progress Issue #1, it's 76 ⁉️

This PR is correct so PR with number 76 is deleted

@quocthangit247 quocthangit247 mentioned this pull request May 10, 2020
21 of 174 tasks complete
Copy link
Contributor

@henryonsoftware henryonsoftware left a comment

@quocthangit247 I have some comments about your PR. Please read and fix what I recommended.

Please help to translate and read again to make sure it naturally meaning with Vietnamese

loadScript('/my/script.js');
```

The function is called "asynchronously," because the action (script loading) finishes not now, but later.
Hàm trên được gọi là "bất đồng bộ," bởi vì hành động (nạp code từ tệp js) không kết thúc ngay lập tức mà sau đó mới hoàn thành xong.

This comment has been minimized.

@henryonsoftware

henryonsoftware May 10, 2020
Contributor

The function is called "asynchronously," should be Hàm trên được gọi "bất đồng bộ,"


If there's a code below `loadScript(…)`, it doesn't wait until the loading finishes.
Hãy xem đoạn code dưới gọi hàm `loadScript(…)`, khi hàm dưới chạy nó sẽ không đợi nạp hết code trong hàm.

This comment has been minimized.

@henryonsoftware

henryonsoftware May 10, 2020
Contributor

Nếu có một đoạn code phía dưới hàm loadScript(…), nó sẽ không đợi quá trình nạp code kết thúc.

// đoạn code trong loadScript
// sẽ không đợi nạp hết code trong hàm
Comment on lines +32 to +33

This comment has been minimized.

@henryonsoftware

henryonsoftware May 10, 2020
Contributor

Update below => phía dưới


But if we do that immediately after the `loadScript(…)` call, that wouldn't work:
Nhưng khi ta gọi lập ngay tức sau hàm `loadScript(…)`, các hàm đó không hoạt động:

This comment has been minimized.

@henryonsoftware

henryonsoftware May 10, 2020
Contributor

lập ngay tức => ngay lập tức

My suggestion:

Nhưng khi ta gọi chúng ngay lập tức sau khi hàm loadScript(...) được gọi, các hàm đó sẽ không hoạt động:

*!*
newFunction(); // no such function!
newFunction(); // không tìm thấy hàm

This comment has been minimized.

@henryonsoftware

henryonsoftware May 10, 2020
Contributor

Please don't remove !


## Pyramid of Doom

From the first look, it's a viable way of asynchronous coding. And indeed it is. For one or maybe two nested calls it looks fine.
Từ cái nhìn đầu tiên, nó là có thể là một cách cách xử lý mã bất đồng bộ. Và quả thật đúng vậy. Cho một hoặc có lẽ hai gọi lồng nhau thì nó cũng ổn.

This comment has been minimized.

@henryonsoftware

henryonsoftware May 10, 2020
Contributor

My suggestion:

Thoạt nhìn, nó khả thi cho xử lý bất đồng bộ. Và đúng vậy thật. Sử dụng một hoặc hai lần gọi lồng nhau thì cũng ổn.

Trong đoạn mã trên:
1. Ta nạp tệp `1.js`, sau đó không có lỗi trả về.
2. Ta nạp tệp `2.js`, sau đó không có lỗi trả về.
3. Ta nạp tệp `3.js`, sau đó không có lỗi trả về -- ta làm hành động gì đó trong else `(*)`.

This comment has been minimized.

@henryonsoftware

henryonsoftware May 10, 2020
Contributor

ta làm hành động gì đó trong else => làm gì đó tiếp tục


As calls become more nested, the code becomes deeper and increasingly more difficult to manage, especially if we have a real code instead of `...`, that may include more loops, conditional statements and so on.
Như cách gọi gọi lồng nhiều cấp trên, đoạn code sẽ trở nên phức tạp hơn để quản lý chúng, đặc biệt nếu ta thực tại ta cần xử lý nhiều hơn ở các chỗ `...`, các chỗ đó có thể nhiều vòng lặp hoặc các điều kiện và hơn thế.

This comment has been minimized.

@henryonsoftware

henryonsoftware May 10, 2020
Contributor

especially if we have a real code instead of ..., that may include more loops, conditional statements and so on.

should be translated

đặc biệt nếu ta có nhiều code hơn thay vì ..., nó có thể chứa nhiều vòng lặp hơn, nhiều điều kiện hơn và hơn thế nữa.

@@ -249,11 +249,11 @@ loadScript('1.js', function(error, script) {

![](callback-hell.svg)

The "pyramid" of nested calls grows to the right with every asynchronous action. Soon it spirals out of control.
"Hình chóp" của gọi lồng nhau tăng trưởng lên đến quyền với mỗi hành động không đồng bộ. Sớm nhất có thể, nó sẽ tăng vùn vụt tới mức không kiểm soát được.

This comment has been minimized.

@henryonsoftware

henryonsoftware May 10, 2020
Contributor

The "pyramid" of nested calls grows to the right with every asynchronous action.

should be translate

"Hình chóp" của việc gọi lồng nhau sẽ phình to sang bên phải ở mỗi lần gọi bất đồng bộ.

}
};
```

See? It does the same, and there's no deep nesting now because we made every action a separate top-level function.
Như bạn thấy? Nó là như nhau, và không có lồng nhiều cấp nữa bởi vì ta đã tạo mỗi hành động là mỗi hàm khác nhau.
Nó có hoạt động, nhưng đoạn mã trông thành nhiều phần khác nhau. Nó khó đọc, và có lẽ bạn nhận cần chú ý hơn khi đọc những hàm trên. Điều đó thật bất tiện, nhất là nếu độc giả chưa quen với mã và không biết cách đọc mã.

This comment has been minimized.

@henryonsoftware

henryonsoftware May 10, 2020
Contributor

  1. Please move this translate to correct where you translated it. Don't remove line-break with the above sentence.

  2. và có lẽ bạn nhận => và có lẽ bạn nhận ra rằng

  3. độc giả => người đọc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.
HTTPS · web.archive.org
← Home