-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Traduction mutations.md
#11
Conversation
Signed-off-by: Bruno Lesieur <bruno.lesieur@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C'est tout pour moi !
docs/en/mutations.md
Outdated
@@ -1,6 +1,6 @@ | |||
# Mutations | |||
|
|||
The only way to actually change state in a Vuex store is by committing a mutation. Vuex mutations are very similar to events: each mutation has a string **type** and a **handler**. The handler function is where we perform actual state modifications, and it will receive the state as the first argument: | |||
La seule façon de vraiment modifier le state dans un store Vuex est de commiter une mutation. Les mutations Vuex sont très similaires aux events : chaque mutation a un **type** sous forme de chaîne de caractères et un **handler**. La fonction handler est là où nous procédons aux véritables modifications du state, et elle reçoit le state en premier argument : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modifier l'état
est d'acter
reçoit l'état
docs/en/mutations.md
Outdated
@@ -16,15 +16,15 @@ const store = new Vuex.Store({ | |||
}) | |||
``` | |||
|
|||
You cannot directly call a mutation handler. The options here is more like event registration: "When a mutation with type `increment` is triggered, call this handler." To invoke a mutation handler, you need to call **store.commit** with its type: | |||
Vous ne pouvez pas appeler directement un handler de mutation. La façon de faire est plutôt comme un abonnement à un event : "Lorsqu'une mutation du type `increment` est déclenchée, appelle ce handler." Pour invoquer un handler de mutation, il faut appeler **store.commit** avec son type : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
à un événement
docs/en/mutations.md
Outdated
@@ -56,7 +56,7 @@ store.commit('increment', { | |||
|
|||
### Object-Style Commit | |||
|
|||
An alternative way to commit a mutation is by directly using an object that has a `type` property: | |||
Une méthode alternative pour commiter une mutation est d'utiliser directement un objet qui a une propriété `type` : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pour acter
docs/en/mutations.md
Outdated
|
||
Since a Vuex store's state is made reactive by Vue, when we mutate the state, Vue components observing the state will update automatically. This also means Vuex mutations are subject to the same reactivity caveats when working with plain Vue: | ||
Puisqu'un state de store de Vuex est rendu réactif par Vue, lorsque nous mutons le state, les composants Vue observant ce state seront automatiquement mis à jour. Cela signifie également que les mutations Vuex sont sujettes aux mêmes inconvénients que lorsqu'on travaille avec Vue : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puisqu'un état de
observant cet état
docs/en/mutations.md
Outdated
|
||
1. Prefer initializing your store's initial state with all desired fields upfront. | ||
1. Initialisez de préférence le state initial de votre state avec tous les champs désirés auparavant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l'état initial de votre état
docs/en/mutations.md
Outdated
|
||
You can commit mutations in components with `this.$store.commit('xxx')`, or use the `mapMutations` helper which maps component methods to `store.commit` calls (requires root `store` injection): | ||
Vous pouvez commiter des mutations dans les composants avec `this.$store.commit('xxx')`, ou en utilisant le helper `mapMutations` qui attache les méthodes du composant aux appels de `store.commit` (nécessite l'injection de `store` à la racine) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vous pouvez acter
docs/en/mutations.md
Outdated
|
||
// mapMutations also supports payloads: | ||
'incrementBy' // this.incrementBy(amount) maps to this.$store.commit('incrementBy', amount) | ||
'increment' // map this.increment() to this.$store.commit('increment') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
map this.increment() à this.$store.commit('increment)
'increment', // map this.increment() to this.$store.commit('increment') | ||
|
||
// mapMutations also supports payloads: | ||
'incrementBy' // this.incrementBy(amount) maps to this.$store.commit('incrementBy', amount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cette partie a disparu.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rajoutée dans 102eb49.
docs/en/mutations.md
Outdated
|
||
// mapMutations also supports payloads: | ||
'incrementBy' // this.incrementBy(amount) maps to this.$store.commit('incrementBy', amount) | ||
'increment' // map this.increment() to this.$store.commit('increment') | ||
]), | ||
...mapMutations({ | ||
add: 'increment' // map this.add() to this.$store.commit('increment') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
map this.add() à this.$store.commit('increment')
docs/en/mutations.md
Outdated
|
||
Asynchronicity combined with state mutation can make your program very hard to reason about. For example, when you call two methods both with async callbacks that mutate the state, how do you know when they are called and which callback was called first? This is exactly why we want to separate the two concepts. In Vuex, **mutations are synchronous transactions**: | ||
L'asynchronisme combiné à la mutation du state peut rendre votre programme très difficile à comprendre. Par exemple, lorsque vous appelez deux méthodes avec toutes les deux des callbacks asynchrones qui changent le state, comment savez-vous quand elles sont appelées et quel callback est appelé en premier ? C'est exactement la raison pour laquelle nous voulons séparer les deux concepts. Avec Vuex, **les mutations sont des transactions synchrones** : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
la mutation de l'état
qui changent l'état
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Un peu de travail de ce côté et une petite reflexion sur le terme « linters » est a envisagé
docs/en/mutations.md
Outdated
@@ -1,6 +1,6 @@ | |||
# Mutations | |||
|
|||
The only way to actually change state in a Vuex store is by committing a mutation. Vuex mutations are very similar to events: each mutation has a string **type** and a **handler**. The handler function is where we perform actual state modifications, and it will receive the state as the first argument: | |||
La seule façon de vraiment modifier le state dans un store Vuex est de commiter une mutation. Les mutations Vuex sont très similaires aux events : chaque mutation a un **type** sous forme de chaîne de caractères et un **handler**. La fonction handler est là où nous procédons aux véritables modifications du state, et elle reçoit le state en premier argument : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modifier l'état
est d'acter
aux évènements
et un gestionnaire
La fonction de gestion est en charge de procéder aux véritables modifications de l'état
@@ -16,15 +16,15 @@ const store = new Vuex.Store({ | |||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
À traduire
muter l'état
docs/en/mutations.md
Outdated
@@ -16,15 +16,15 @@ const store = new Vuex.Store({ | |||
}) | |||
``` | |||
|
|||
You cannot directly call a mutation handler. The options here is more like event registration: "When a mutation with type `increment` is triggered, call this handler." To invoke a mutation handler, you need to call **store.commit** with its type: | |||
Vous ne pouvez pas appeler directement un handler de mutation. La façon de faire est plutôt comme un abonnement à un event : "Lorsqu'une mutation du type `increment` est déclenchée, appelle ce handler." Pour invoquer un handler de mutation, il faut appeler **store.commit** avec son type : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
un gestionnaire de mutation.
Le partie pris ici est similaire à l'abonnement à un évènement : « ... ce gestionnaire. »
un gestionnaire de mutation
appeler
store.commit
docs/en/mutations.md
Outdated
|
||
``` js | ||
store.commit('increment') | ||
``` | ||
|
||
### Commit with Payload | ||
### commiter avec un Payload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acter avec un argument additionnel
docs/en/mutations.md
Outdated
|
||
You can pass an additional argument to `store.commit`, which is called the **payload** for the mutation: | ||
Vous pouvez donner un autre argument à **store.commit** pour la mutation, qui s'appelle **payload** : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vous pouvez donner un argument additionnel (« payload ») à la fonction
store.commit
lors de la mutation :
docs/en/mutations.md
Outdated
@@ -133,11 +133,11 @@ mutations: { | |||
} | |||
``` | |||
|
|||
Now imagine we are debugging the app and looking at the devtool's mutation logs. For every mutation logged, the devtool will need to capture a "before" and "after" snapshots of the state. However, the asynchronous callback inside the example mutation above makes that impossible: the callback is not called yet when the mutation is committed, and there's no way for the devtool to know when the callback will actually be called - any state mutation performed in the callback is essentially un-trackable! | |||
Maintenant imaginons que nous debuggons l'application et que nous regardons dans les logs de mutation des devtools. Pour chaque mutation enregistrée, le devtool aura besoin de capturer un instantané du state "avant" et un instantané "après". Cependant, le callback asynchrone du l'exemple ci-dessus rend l'opération impossible : le callback n'est pas encore appelé lorsque la mutation est committée, et il n'y a aucun moyen pour le devtool de savoir quand le callback sera véritablement appelé — toute mutation du state effectuée dans le callack est essentiellement intraçable ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deboguons
des outils de développement (« devtools »)
« avant »
« après »
la fonction de rappel asynchrone
la fonction de rappel n'est pas encore appelée
la mutation est actée
quand la fonction de rappel
appelée. Toute mutation de l'état effectuée dans une fonction de rappel asynchrone
docs/en/mutations.md
Outdated
|
||
### Committing Mutations in Components | ||
### commiter des mutations dans les composants |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acter
docs/en/mutations.md
Outdated
|
||
You can commit mutations in components with `this.$store.commit('xxx')`, or use the `mapMutations` helper which maps component methods to `store.commit` calls (requires root `store` injection): | ||
Vous pouvez commiter des mutations dans les composants avec `this.$store.commit('xxx')`, ou en utilisant le helper `mapMutations` qui attache les méthodes du composant aux appels de `store.commit` (nécessite l'injection de `store` à la racine) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pouvez acter
la fonction utilitaire
mapMutations
@@ -158,14 +155,14 @@ export default { | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
À traduire
docs/en/mutations.md
Outdated
|
||
Asynchronicity combined with state mutation can make your program very hard to reason about. For example, when you call two methods both with async callbacks that mutate the state, how do you know when they are called and which callback was called first? This is exactly why we want to separate the two concepts. In Vuex, **mutations are synchronous transactions**: | ||
L'asynchronisme combiné à la mutation du state peut rendre votre programme très difficile à comprendre. Par exemple, lorsque vous appelez deux méthodes avec toutes les deux des callbacks asynchrones qui changent le state, comment savez-vous quand elles sont appelées et quel callback est appelé en premier ? C'est exactement la raison pour laquelle nous voulons séparer les deux concepts. Avec Vuex, **les mutations sont des transactions synchrones** : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
de l'état
fonctions de rappel asynchrones qui change l'état
fonction de rappel est appelée en première ?
docs/en/mutations.md
Outdated
|
||
Asynchronicity combined with state mutation can make your program very hard to reason about. For example, when you call two methods both with async callbacks that mutate the state, how do you know when they are called and which callback was called first? This is exactly why we want to separate the two concepts. In Vuex, **mutations are synchronous transactions**: | ||
L'asynchronisme combiné à la mutation du state peut rendre votre programme très difficile à comprendre. Par exemple, lorsque vous appelez deux méthodes avec toutes les deux des callbacks asynchrones qui changent le state, comment savez-vous quand elles sont appelées et quel callback est appelé en premier ? C'est exactement la raison pour laquelle nous voulons séparer les deux concepts. Avec Vuex, **les mutations sont des transactions synchrones** : | ||
|
||
``` js | ||
store.commit('increment') | ||
// any state change that the "increment" mutation may cause | ||
// should be done at this moment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
À traduire
Si c'est bon pour toi @Kocal, on merge. Je vais faire une PR en pour remettre les ticks dans l'original. |
Ok pour moi :) |
À priori le nombre de ligne à changé. Il doit y avoir du nouveau par ici :)