Skip to content

Translate bahasa indonesia dari : Vue Computed Property & Watcher #59

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

Merged
merged 7 commits into from
Mar 7, 2019

Conversation

iqbalaqaba
Copy link

Hasil translate bahasa indonesia dari : Vue Computed Property & Watcher 🚀

@@ -1,60 +1,61 @@
---
title: Computed Properties and Watchers
title: Pengamat dan properti penghitung
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tetep tambahin aslinya mas, Properti Penghitung (Computed) dan Pengamat (Watchers)

type: guide
order: 5
---

## Computed Properties
## Properti Penghitung (Computed Properties)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yang dikurung cukup computed aja.
Properti sudah cukup familiar

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tapi sebenarnya sudah gak perlu lagi, karena di title kita sudah kasih tau yang kita maksud adalah computed.
Jadi bisa pakai Properti Penghitung tanpa kurung lagi

## Computed Properties
## Properti Penghitung (Computed Properties)

Pernyataan *In-template* sangatlah mudah, tapi mereka dibuat untuk operasi yang sederhana. Memberikan terlalu banyak logika di *template* anda dapat menyebabkan mereka berat dan susah untuk dipelihara. Sebagai Contoh :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tapi mereka -> tapi hal tersebut

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dapat menyebabkan mereka berat -> dapat menyebabkan menjadi berat


``` html
<div id="example">
{{ message.split('').reverse().join('') }}
</div>
```

At this point, the template is no longer simple and declarative. You have to look at it for a second before realizing that it displays `message` in reverse. The problem is made worse when you want to include the reversed message in your template more than once.
Pada poin ini, *template* tidak lagi sederhana dan deklaratif. Anda harus melihat itu untuk beberapa saat sebelum menyadari bahwa itu menampilkan *`message`* secara terbalik. Masalahnya diperburuk ketika anda ingin memasukan pesan terbalik itu kedalam *template* anda lebih dari sekali.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ganti anda jadi Anda


That's why for any complex logic, you should use a **computed property**.
Itulah kenapa, untuk logika yang kompleks, anda harus menggunakan **properti penghitung**.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Koma disini jadi gak cocok.
Kenapa diganti dengan mengapa


You can data-bind to computed properties in templates just like a normal property. Vue is aware that `vm.reversedMessage` depends on `vm.message`, so it will update any bindings that depend on `vm.reversedMessage` when `vm.message` changes. And the best part is that we've created this dependency relationship declaratively: the computed getter function has no side effects, which makes it easier to test and understand.
Anda bisa melakukan *data-bind* ke properti penghitung di *template* seperti properti normal. Vue sadar bahwa `vm.reversedMessage` tergantung dengan `vm.message`, jadi itu akan merubah semua yang terkait dengan `vm.reversedMessage` ketika `vm.message` berubah. Dan bagian terbaiknya adalah kita telah membuat hubungan *dependency* secara deklaratif : penghitung fungsi *getter* tidak mempunyai efek samping, yang membuat itu menjadi lebih mudah untuk di coba dan di pahami.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

di coba -> dicoba
di pahami -> dipahami

methods: {
reverseMessage: function () {
return this.message.split('').reverse().join('')
}
}
```

Instead of a computed property, we can define the same function as a method instead. For the end result, the two approaches are indeed exactly the same. However, the difference is that **computed properties are cached based on their dependencies.** A computed property will only re-evaluate when some of its dependencies have changed. This means as long as `message` has not changed, multiple access to the `reversedMessage` computed property will immediately return the previously computed result without having to run the function again.
Selain properti penghitung, kita dapat menetapkan fungsi yang sama sebagai metode. Untuk hasil akhirnya, dua pendekatan memang sama persis. Tetapi, perbedaanya adalah **properti penghitung *(computed property)* di simpan berdasarkan *dependencies* mereka.** Sebuah properti penghitung hanya akan mengevaluasi ulang ketika salah satu *dependencies* mereka telah berubah. Ini berarti selama `message` belum berubah, semua akses ke `reversedMessage` properti penghitung akan langsung kembali ke hasil penghitungan sebelumnya tanpa harus menjalankan ulang fungsi tersebut
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sudah gak perlu dijelaskan pakai (computed property)


### Computed vs Watched Property
### Properti Penghitung (Computed Property) vs Properti Pengawas (Watched Property)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ini juga udah gak perlu kurung lagi

@mazipan
Copy link
Member

mazipan commented Mar 7, 2019

Udah beres ya mas @iqbalaqaba ? Saya merge ya

@mazipan mazipan merged commit d601ab8 into vuejs-id:master Mar 7, 2019
@iqbalaqaba
Copy link
Author

Mantap mas @mazipan thank you 😄

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

Successfully merging this pull request may close these issues.

2 participants