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

自己写一个 redux #7386

Merged
merged 17 commits into from
Jan 31, 2021
Merged

Conversation

tanglie1993
Copy link
Contributor

译文翻译完成,resolve #7279

@nia3y
Copy link
Contributor

nia3y commented Sep 10, 2020

校对认领 @fanyijihua @lsvih

@lsvih
Copy link
Member

lsvih commented Sep 10, 2020

@nia3y 好的!

Copy link
Contributor

@nia3y nia3y left a comment

Choose a reason for hiding this comment

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

@tanglie1993 @lsvih 校对完成
希望译者注意下格式问题wiki 百科


Note that technically we'll be building [Redux](https://github.com/reactjs/redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier) **and** [React Redux](https://github.com/reactjs/react-redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier). At Zapier, we pair Redux with the (awesome) UI library [React](https://facebook.github.io/react/), and that's the pairing that shows up most in the wild. But even if you use Redux with something else, most everything here will still apply.
注意,实际上我们将会实现的是 [Redux](https://github.com/reactjs/redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier) **** [React Redux](https://github.com/reactjs/react-redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier)。在这里,我们把 Redux with 和著名的 UI [React](https://facebook.github.io/react/) 相结合,而这正是在实际场景中最为常见的组合。哪怕你把 Redux 和其他东西组合,这里讲解的所有东西几乎也还是一样的。
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
注意,实际上我们将会实现的是 [Redux](https://github.com/reactjs/redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier) **** [React Redux](https://github.com/reactjs/react-redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier)。在这里,我们把 Redux with 和著名的 UI 库 [React](https://facebook.github.io/react/) 相结合,而这正是在实际场景中最为常见的组合。哪怕你把 Redux 和其他东西组合,这里讲解的所有东西几乎也还是一样的
注意,实际上我们将会实现的是 [Redux](https://github.com/reactjs/redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier) **** [React Redux](https://github.com/reactjs/react-redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier)。在这里,我们把 Redux 和著名的 UI 库 [React](https://facebook.github.io/react/) 相结合,而这正是在实际场景中最为常见的组合。哪怕你把 Redux 和其他库相组合,这里讲解的大部分内容仍然适用


Most useful apps will get their state from a server, but let's start by creating our state locally. Even if we are retrieving from the server, we have to seed the app with something anyway. Our app will be a simple note-taking app. This is mostly to avoid making yet another todo app, but it will also force us to make an interesting state decision later.
大多数有用的应用从服务端获取状态。但我们先从本地创建状态开始。哪怕我们从服务端获取,也要用一些东西把应用先初始化的。我们的应用将会是一个简单的笔记应用。这主要是为了防止写一个新的清单应用,但是它也可以迫使我们做一个有趣的关于状态的决定。
Copy link
Contributor

Choose a reason for hiding this comment

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

【也要用一些东西把应用先初始化的】=>【也要先用一些状态初始化应用】
【这主要是为了防止写一个新的清单应用】=>【这主要是为了防止写另一个清单应用】

article/2020/how-to-build-redux.md Outdated Show resolved Hide resolved
article/2020/how-to-build-redux.md Outdated Show resolved Hide resolved
article/2020/how-to-build-redux.md Outdated Show resolved Hide resolved
article/2020/how-to-build-redux.md Outdated Show resolved Hide resolved
article/2020/how-to-build-redux.md Outdated Show resolved Hide resolved
article/2020/how-to-build-redux.md Outdated Show resolved Hide resolved
Comment on lines 1113 to 1115
如果中间件决定要发出一个新的 action,这个 action 将会通过中间件传递下去。
我们需要创建这个函数,因为我们即将修改 store 的 `dispatch` 方法。
这是另一个修改对象的例子,它可以简化问题。Redux 可以破坏规则,只要它能够帮助开发者遵循规则。:-)
Copy link
Contributor

Choose a reason for hiding this comment

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

注:这三个是一段的,希望修改一下

@@ -1121,9 +1121,9 @@ store.dispatch = middleware({
})(coreDispatch);
```

That calls the middleware, passing it an object that has access to our re-dispatch function as well as our `getState` function. The middleware should return a new function that accepts the ability to call the next dispatch function, which in this case is just the original dispatch function. If your head is spinning a little, don't worry, creating and using middleware is actually pretty easy.
这调用了中间件,传给它一个能访问 "重新dispatch" 函数和 `getState` 函数的对象。这个中间件应该返回一个新的函数,它接收调用下一个 dispatch 函数的函数(在这里就是原始的 dispatch 函数)。如果你读到这里觉得头晕了,不要担心。创建和使用中间件实际上是很容易的。
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
这调用了中间件,传给它一个能访问 "重新dispatch" 函数和 `getState` 函数的对象。这个中间件应该返回一个新的函数,它接收调用下一个 dispatch 函数的函数(在这里就是原始的 dispatch 函数)。如果你读到这里觉得头晕了,不要担心。创建和使用中间件实际上是很容易的。
这调用了中间件,传给它一个能进行“re-dispatch ”的函数和 `getState` 的函数。这个中间件应该返回一个新的函数,拥有用来接收调用下一个 dispatch 函数的能力(在这里就是原始的 dispatch 函数)。如果你读到这里觉得头晕了,不要担心。创建和使用中间件实际上是很容易的。

@rachelcdev
Copy link

@lsvih 校对认领

@lsvih
Copy link
Member

lsvih commented Sep 13, 2020

@rachelcdev 好的!

@JohnieXu
Copy link
Contributor

@lsvih 校对认领

@lsvih
Copy link
Member

lsvih commented Oct 14, 2020

@JohnieXu 好的~

Copy link
Contributor

@JohnieXu JohnieXu left a comment

Choose a reason for hiding this comment

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

通篇校对下来,发现整篇文章就是用翻译工具翻译的,这会给校对者增加非常多的工作量。建议下:即使采用翻译工具翻译的,也最好翻译者自己仔细阅读一下译文。


Note that technically we'll be building [Redux](https://github.com/reactjs/redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier) **and** [React Redux](https://github.com/reactjs/react-redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier). At Zapier, we pair Redux with the (awesome) UI library [React](https://facebook.github.io/react/), and that's the pairing that shows up most in the wild. But even if you use Redux with something else, most everything here will still apply.
注意,实际上我们将会实现的是 [Redux](https://github.com/reactjs/redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier) **** [React Redux](https://github.com/reactjs/react-redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier)。在这里,我们把 Redux with 和著名的 UI [React](https://facebook.github.io/react/) 相结合,而这正是在实际场景中最为常见的组合。哪怕你把 Redux 和其他东西组合,这里讲解的所有东西几乎也还是一样的。
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
注意,实际上我们将会实现的是 [Redux](https://github.com/reactjs/redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier) **** [React Redux](https://github.com/reactjs/react-redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier)。在这里,我们把 Redux with 和著名的 UI 库 [React](https://facebook.github.io/react/) 相结合,而这正是在实际场景中最为常见的组合。哪怕你把 Redux 和其他东西组合,这里讲解的所有东西几乎也还是一样的。
注意,实际上我们将会实现的是 [Redux](https://github.com/reactjs/redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier) **** [React Redux](https://github.com/reactjs/react-redux?utm_source=zapier.com&utm_medium=referral&utm_campaign=zapier)。在这里,我们把 Redux 和著名的 UI 库 [React](https://facebook.github.io/react/) 相结合,而这正是在实际场景中最为常见的组合。哪怕你把 Redux 和其他东西组合,这里讲解的所有东西几乎也还是一样的。


Most useful apps will get their state from a server, but let's start by creating our state locally. Even if we are retrieving from the server, we have to seed the app with something anyway. Our app will be a simple note-taking app. This is mostly to avoid making yet another todo app, but it will also force us to make an interesting state decision later.
大多数有用的应用从服务端获取状态。但我们先从本地创建状态开始。哪怕我们从服务端获取,也要用一些东西把应用先初始化的。我们的应用将会是一个简单的笔记应用。这主要是为了防止写一个新的清单应用,但是它也可以迫使我们做一个有趣的关于状态的决定。
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
大多数有用的应用从服务端获取状态。但我们先从本地创建状态开始。哪怕我们从服务端获取,也要用一些东西把应用先初始化的。我们的应用将会是一个简单的笔记应用。这主要是为了防止写一个新的清单应用,但是它也可以迫使我们做一个有趣的关于状态的决定
虽然大多数真实项目都需要从服务端获取数据作为应用状态,但我们还是先从本地创建状态开始。即使是从服务端获取,也要需要先用本地数据初始化应用的状态对象。为了不再重复写一个待办清单应用,我们将创建一个简单的笔记应用,同时它也可以迫使我们做一个有趣的关于状态的决定

Copy link
Contributor

Choose a reason for hiding this comment

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

建议这里稍微意译处理一下,这样更通顺


## Why Redux?
## 为什么是 Redux?
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
## 为什么是 Redux?
## 为何使用 Redux


Before we dig any deeper, let's see what it's like to build our app without Redux. Let's just go ahead and attach our `initialState` object to `window` like this:
在我们继续深入之前,首先来看看不使用 Redux 开发我们的应用是什么样。直接开始,把我们的 `initialState` 对象绑定到 `window` 上,像这样:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
在我们继续深入之前,首先来看看不使用 Redux 开发我们的应用是什么样。直接开始,把我们的 `initialState` 对象绑定到 `window` 上,像这样:
在我们继续深入之前,首先来看看不使用 Redux 要怎样开发我们创建的应用。直接开始,把我们的 `initialState` 对象绑定到 `window` 上,像这样:


```js
window.state = initialState;
```

Boom, there's our store! We don't need no stinking Redux. Let's make a component that adds new notes.
嘣,这就是我们的 store!我们不需要什么 Redux。来做一个添加新笔记的组件吧。
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
嘣,这就是我们的 store我们不需要什么 Redux。来做一个添加新笔记的组件吧
这就是我们的状态对象(store),我们不需要什么 Redux,下面来添加一个新的笔记组件吧

article/2020/how-to-build-redux.md Outdated Show resolved Hide resolved
article/2020/how-to-build-redux.md Outdated Show resolved Hide resolved
article/2020/how-to-build-redux.md Outdated Show resolved Hide resolved
article/2020/how-to-build-redux.md Outdated Show resolved Hide resolved
article/2020/how-to-build-redux.md Show resolved Hide resolved
@JohnieXu
Copy link
Contributor

@lsvih @tanglie1993 校对完成,希望能修改一下

@lsvih lsvih added enhancement 等待译者修改 and removed 正在校对 labels Oct 18, 2020
@tanglie1993
Copy link
Contributor Author

@lsvih 修改完毕。

@lsvih lsvih added 标注 待管理员 Review and removed enhancement 等待译者修改 labels Oct 21, 2020
@lsvih
Copy link
Member

lsvih commented Oct 24, 2020

@tanglie1993 啊这篇文章中间还有几十个校对意见没有修改或者回应呢= =您是不是漏了

Co-authored-by: niayyy <yy761706@gmail.com>
Co-authored-by: JohnieXu <281910378@qq.com>
lsvih and others added 5 commits January 17, 2021 17:47
Co-authored-by: niayyy <yy761706@gmail.com>
Co-authored-by: JohnieXu <281910378@qq.com>
Co-authored-by: niayyy <yy761706@gmail.com>
Co-authored-by: JohnieXu <281910378@qq.com>
Co-authored-by: niayyy <yy761706@gmail.com>
Co-authored-by: JohnieXu <281910378@qq.com>
@lsvih lsvih merged commit 01d8da6 into xitu:master Jan 31, 2021
@lsvih lsvih added 翻译完成 and removed 标注 待管理员 Review labels Jan 31, 2021
@lsvih
Copy link
Member

lsvih commented Jan 31, 2021

已发布:https://juejin.cn/post/6923922875191656462

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

Successfully merging this pull request may close these issues.

自己写一个 redux
5 participants