Skip to content
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

Merged
merged 3 commits into from
May 22, 2017
Merged

Traduction mutations.md #11

merged 3 commits into from
May 22, 2017

Conversation

MachinisteWeb
Copy link
Member

@MachinisteWeb MachinisteWeb commented May 20, 2017

À priori le nombre de ligne à changé. Il doit y avoir du nouveau par ici :)

Signed-off-by: Bruno Lesieur <bruno.lesieur@gmail.com>
Copy link
Member

@Kocal Kocal left a 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 !

@@ -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 :
Copy link
Member

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

@@ -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 :
Copy link
Member

Choose a reason for hiding this comment

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

à un événement

@@ -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` :
Copy link
Member

Choose a reason for hiding this comment

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

pour acter


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 :
Copy link
Member

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


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.
Copy link
Member

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


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) :
Copy link
Member

Choose a reason for hiding this comment

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

Vous pouvez acter


// mapMutations also supports payloads:
'incrementBy' // this.incrementBy(amount) maps to this.$store.commit('incrementBy', amount)
'increment' // map this.increment() to this.$store.commit('increment')
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

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

Cette partie a disparu.

Copy link
Member

Choose a reason for hiding this comment

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

Rajoutée dans 102eb49.


// 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')
Copy link
Member

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')


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** :
Copy link
Member

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

Copy link
Member Author

@MachinisteWeb MachinisteWeb left a 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é

@@ -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 :
Copy link
Member Author

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({
})
Copy link
Member Author

Choose a reason for hiding this comment

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

À traduire

muter l'état

@@ -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 :
Copy link
Member Author

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


``` js
store.commit('increment')
```

### Commit with Payload
### commiter avec un Payload
Copy link
Member Author

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


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** :
Copy link
Member Author

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 :

@@ -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é &mdash; toute mutation du state effectuée dans le callack est essentiellement intraçable !
Copy link
Member Author

@MachinisteWeb MachinisteWeb May 20, 2017

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


### Committing Mutations in Components
### commiter des mutations dans les composants
Copy link
Member Author

Choose a reason for hiding this comment

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

Acter


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) :
Copy link
Member Author

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 {
}
Copy link
Member Author

Choose a reason for hiding this comment

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

À traduire


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** :
Copy link
Member Author

@MachinisteWeb MachinisteWeb May 20, 2017

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 ?

Signed-off-by: Bruno Lesieur <bruno.lesieur@gmail.com>

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.
Copy link
Member Author

Choose a reason for hiding this comment

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

À traduire

@MachinisteWeb
Copy link
Member Author

Si c'est bon pour toi @Kocal, on merge. Je vais faire une PR en pour remettre les ticks dans l'original.

@Kocal
Copy link
Member

Kocal commented May 22, 2017

Ok pour moi :)

@MachinisteWeb MachinisteWeb merged commit e17989a into working May 22, 2017
@MachinisteWeb MachinisteWeb deleted the mutation branch May 22, 2017 13:03
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants