You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/v2/guide/state-management.md
+16-16Lines changed: 16 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,22 @@
1
1
---
2
-
title: State Management
2
+
title: Pengelolaan State
3
3
type: guide
4
4
order: 502
5
5
---
6
6
7
-
## Official Flux-Like Implementation
7
+
## Implementasi Flux-Like (Sejenis Flux) Resmi
8
8
9
-
Large applications can often grow in complexity, due to multiple pieces of state scattered across many components and the interactions between them. To solve this problem, Vue offers[vuex](https://github.com/vuejs/vuex): our own Elm-inspired state management library. It even integrates into [vue-devtools](https://github.com/vuejs/vue-devtools), providing zero-setup access to[time travel debugging](https://github.com/raw/vuejs/vue-devtools/master/media/demo.gif).
9
+
Aplikasi besar bisa tumbuh menjadi sangat kompleks, dikarenakan banyak sekali bagian dari state yang tersebar ke seluruh komponen dan berinteraksi dengan mereka. Untuk mengatasi masalah ini, Vue menawarkan[vuex](https://github.com/vuejs/vuex): Sebuah pustaka yang berfungsi untuk mengelola state buatan kami sendiri. Ia bahkan mampu terintegrasi dengan [vue-devtools](https://github.com/vuejs/vue-devtools), dan juga kita tidak perlu mempersiapkan apa-apa (tidak perlu melakukan konfigurasi khusus) untuk bisa mengakses[time travel debugging](https://github.com/raw/vuejs/vue-devtools/master/media/demo.gif).
10
10
11
-
<divclass="vue-mastery"><ahref="https://www.vuemastery.com/courses/mastering-vuex/intro-to-vuex/"target="_blank"rel="noopener"title="Vuex Tutorial">Watch a video explanation on Vue Mastery</a></div>
11
+
<divclass="vue-mastery"><ahref="https://www.vuemastery.com/courses/mastering-vuex/intro-to-vuex/"target="_blank"rel="noopener"title="Vuex Tutorial">Tonton video penjelasannya di Vue Mastery</a></div>
12
12
13
-
### Information for React Developers
13
+
### Informasi untuk Developer React
14
14
15
-
If you're coming from React, you may be wondering how vuex compares to [redux](https://github.com/reactjs/redux), the most popular Flux implementation in that ecosystem. Redux is actually view-layer agnostic, so it can easily be used with Vue via [simple bindings](https://yarnpkg.com/en/packages?q=redux%20vue&p=1). Vuex is different in that it _knows_ it's in a Vue app. This allows it to better integrate with Vue, offering a more intuitive API and improved development experience.
15
+
Jika Anda pernah menggunakan React, Anda mungkin ingin tahu perbandingan antara vuex dengan [redux](https://github.com/reactjs/redux), sebuah pustaka untuk implementasi Flux yang paling populer. Redux sebenarnya tidak tergantung pada suatu lapisan tampilan, jadi bisa digunakan bersama - sama dengan Vue secara mudah melalui [simple bindings](https://yarnpkg.com/en/packages?q=redux%20vue&p=1). Vuex berbeda karena ia langsung terhubung dengan aplikasi Vue. Oleh karena itu, Vuex lebih cocok jika di integrasikan dengan Vue, dan juga Vuex menawarkan API yang lebih intuitif dan mampu meningkatkan pengalaman para pengembang.
16
16
17
-
## Simple State Management from Scratch
17
+
## Pengelolaan State Sederhana dari Awal
18
18
19
-
It is often overlooked that the source of truth in Vue applications is the raw `data`object - a Vue instance only proxies access to it. Therefore, if you have a piece of state that should be shared by multiple instances, you can share it by identity:
19
+
Hal ini seringkali diabaikan bahwa sumber kebenaran di aplikasi Vue adalah objek `data`yang mentah - hanya *instance* Vue yang boleh mengaksesnya. Oleh karena itu, jika Anda memiliki beberapa state yang ingin di bagikan ke beberapa *instance*, Anda bisa membaginya dengan identitas:
20
20
21
21
```js
22
22
constsourceOfTruth= {}
@@ -30,9 +30,9 @@ const vmB = new Vue({
30
30
})
31
31
```
32
32
33
-
Now whenever`sourceOfTruth`is mutated, both`vmA`and`vmB`will update their views automatically. Subcomponents within each of these instances would also have access via `this.$root.$data`. We have a single source of truth now, but debugging would be a nightmare. Any piece of data could be changed by any part of our app at any time, without leaving a trace.
33
+
Sekarang saat`sourceOfTruth`dirubah, kedua`vmA`dan`vmB`akan mengubah tampilan mereka secara otomatis. Sub komponen dalam beberapa *instance* ini juga perlu mengaksesnya dengan cara menggunakan perintah `this.$root.$data`. Sekarang kita punya satu sourceOfTruth, namun melakukan debugging akan sangat sulit sekali. Setiap data bisa dirubah oleh setiap bagian dari aplikasi kita setiap waktunya, tanpa meninggalkan jejak.
34
34
35
-
To help solve this problem, we can adopt a **store pattern**:
35
+
Untuk memecahkan masalah ini, kita bisa menggunakan **pola penyimpanan**:
36
36
37
37
```js
38
38
var store = {
@@ -51,9 +51,9 @@ var store = {
51
51
}
52
52
```
53
53
54
-
Notice all actions that mutate the store's state are put inside the store itself. This type of centralized state management makes it easier to understand what type of mutations could happen and how they are triggered. Now when something goes wrong, we'll also have a log of what happened leading up to the bug.
54
+
Perhatikan semua *action* yang mengubah *state* dari *store* diletakkan didalam *store* itu sendiri. Tipe pengelolaan state yang terpusat ini membuatnya semakin mudah untuk dimengerti bahwa tipe perubahan apa saja yang bisa terjadi dan bagaimana mereka dijalankan. Sekarang saat terjadi kesalahan, kita juga memiliki sebuah catatan kenapa bisa terjadi bug.
55
55
56
-
In addition, each instance/component can still own and manage its own private state:
56
+
Sebagai tambahan, setiap *instance*/komponen tetap bisa memiliki dan mengelola state milik mereka sendiri:
57
57
58
58
```js
59
59
var vmA =newVue({
@@ -71,10 +71,10 @@ var vmB = new Vue({
71
71
})
72
72
```
73
73
74
-

74
+

75
75
76
-
<pclass="tip">It's important to note that you should never replace the original state object in your actions - the components and the store need to share reference to the same object in order for mutations to be observed.</p>
76
+
<pclass="tip">Sebagai catatan penting, Anda jangan pernah menggantikan state asli pada *action* yang Anda buat - komponen dan *store* perlu untuk berbagi data referensi kedalam objek yang sama supaya perubahan bisa diamati.</p>
77
77
78
-
As we continue developing the convention where components are never allowed to directly mutate state that belongs to a store, but should instead dispatch events that notify the store to perform actions, we eventually arrive at the [Flux](https://facebook.github.io/flux/) architecture. The benefit of this convention is we can record all state mutations happening to the store and implement advanced debugging helpers such as mutation logs, snapshots, and history re-rolls / time travel.
78
+
Saat kita melanjutkan pengembangan, ketentuannya adalah komponen tidak boleh merubah *state* yang ada di dalam *store* secara langsung, tetapi kita harus mengirim sebuah *event* untuk memberitahu *store* bahwa dia harus menjalankan sebuah *action*, yang pada akhirnya kita akan merasakan proses seperti ini sama dengan dengan arsitektur milik [Flux](https://facebook.github.io/flux/). Keuntungan menggunakan aturan ini adalah kita bisa merekam semua perubahan *state* yang terjadi pada *store* dan bisa mengimplementasikan proses *debugging helpers* seperti catatan perubahan, *snapshot*, dan bisa melihat perubahan data secara historis/*time travel*.
79
79
80
-
This brings us full circle back to [vuex](https://github.com/vuejs/vuex), so if you've read this far it's probably time to try it out!
80
+
Mari kembali lagi ke [vuex](https://github.com/vuejs/vuex), jadi jika Anda telah membaca panduan pengelolaan *state* sampai sejauh ini, mungkin sekarang saatnya mencoba!
0 commit comments