Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Migrate website to Docusaurus 2 #471

Merged
merged 2 commits into from
Jul 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Flux
An application architecture for React utilizing a unidirectional data flow.

<img src="./docs/img/flux-diagram-white-background.png" style="width: 100%;" />
<img src="./img/flux-diagram-white-background.png" style="width: 100%;" />

## Getting Started

Expand Down
36 changes: 16 additions & 20 deletions docs/Dispatcher.ko-KR.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
---
id: dispatcher-ko-KR
title: Dispatcher
layout: docs
category: Reference
permalink: docs/dispatcher-ko-KR.html
next: videos-ko-KR
lang: ko-KR
---

Dispatcher는 등록된 callback에 데이터를 중계할 때 사용된다. 일반적인 pub-sub 시스템과는 다음 두 항목이 다르다:
Expand All @@ -17,24 +12,24 @@ Dispatcher는 등록된 callback에 데이터를 중계할 때 사용된다. 일

## API

- **register(function callback): string**
모든 데이터 변동이 있을 때 실행될 콜백을 등록한다. `waitFor()`에서 사용 가능한 토큰을 반환한다.
- **`register(function callback): string`**
모든 데이터 변동이 있을 때 실행될 콜백을 등록한다. `waitFor()`에서 사용 가능한 토큰을 반환한다.

- **unregister(string id): void**
토큰으로 콜백을 제거한다.
- **`unregister(string id): void`**
토큰으로 콜백을 제거한다.

- **waitFor(array<string> ids): void**
현재 실행한 콜백이 진행되기 전에 특정 콜백을 지연하게 한다. 데이터 변동에 응답하는 콜백에만 사용해야 한다.
- **`waitFor(array<string> ids): void`**
현재 실행한 콜백이 진행되기 전에 특정 콜백을 지연하게 한다. 데이터 변동에 응답하는 콜백에만 사용해야 한다.

- **dispatch(object payload): void** 등록된 모든 콜백에 데이터를 전달한다.
- **`dispatch(object payload): void`** 등록된 모든 콜백에 데이터를 전달한다.

- **isDispatching(): boolean** 이 Dispatcher가 지금 데이터를 전달하고 있는지 확인한다.
- **`isDispatching(): boolean`** 이 Dispatcher가 지금 데이터를 전달하고 있는지 확인한다.

## 예시

가상의 비행 목적지 양식에서 국가를 선택했을 때 기본 도시를 선택하는 예를 보자:

```
```js
var flightDispatcher = new Dispatcher();

// 어떤 국가를 선택했는지 계속 추적한다
Expand All @@ -49,7 +44,7 @@ var FlightPriceStore = {price: null};

사용자가 선택한 도시를 변경하면 데이터를 전달한다:

```
```js
flightDispatcher.dispatch({
actionType: 'city-update',
selectedCity: 'paris'
Expand All @@ -58,7 +53,7 @@ flightDispatcher.dispatch({

이 데이터 변동은 `CityStore`가 소화한다:

```
```js
flightDispatcher.register(function(payload) {
if (payload.actionType === 'city-update') {
CityStore.city = payload.selectedCity;
Expand All @@ -68,7 +63,7 @@ flightDispatcher.register(function(payload) {

사용자가 국가를 선택하면 데이터를 전달한다:

```
```js
flightDispatcher.dispatch({
actionType: 'country-update',
selectedCountry: 'australia'
Expand All @@ -77,17 +72,18 @@ flightDispatcher.dispatch({

이 데이터는 두 store에 의해 소화된다:

```
```js
CountryStore.dispatchToken = flightDispatcher.register(function(payload) {
if (payload.actionType === 'country-update') {
CountryStore.country = payload.selectedCountry;
}
});
```

`CountryStore`가 등록한 콜백을 업데이트 할 때 반환되는 토큰을 참조값으로 저장했다. 이 토큰은 `waitFor()`
에서 사용할 수 있고 `CityStore`가 갱신하는 것보다 먼저 `CountryStore`를 갱신하도록 보장할 수 있다.

```
```js
CityStore.dispatchToken = flightDispatcher.register(function(payload) {
if (payload.actionType === 'country-update') {
// `CountryStore.country`는 업데이트 되지 않는다
Expand All @@ -102,7 +98,7 @@ CityStore.dispatchToken = flightDispatcher.register(function(payload) {

`waitFor()`는 다음과 같이 묶을 수 있다:

```
```js
FlightPriceStore.dispatchToken =
flightDispatcher.register(function(payload) {
switch (payload.actionType) {
Expand Down
38 changes: 17 additions & 21 deletions docs/Dispatcher.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,39 @@
---
id: dispatcher
title: Dispatcher
layout: docs
category: Reference
permalink: docs/dispatcher.html
next: flux-utils
---

Dispatcher is used to broadcast payloads to registered callbacks. This is
different from generic pub-sub systems in two ways:

- Callbacks are not subscribed to particular events. Every payload is
dispatched to every registered callback.
dispatched to every registered callback.
- Callbacks can be deferred in whole or part until other callbacks have
been executed.
been executed.

Check out [Dispatcher.js](https://github.com/facebook/flux/blob/master/src/Dispatcher.js) for the source code.

## API

- **register(function callback): string**
Registers a callback to be invoked with every dispatched payload. Returns a token that can be used with `waitFor()`.
- **`register(function callback): string`**
Registers a callback to be invoked with every dispatched payload. Returns a token that can be used with `waitFor()`.

- **unregister(string id): void**
Removes a callback based on its token.
- **`unregister(string id): void`**
Removes a callback based on its token.

- **waitFor(array<string> ids): void**
Waits for the callbacks specified to be invoked before continuing execution of the current callback. This method should only be used by a callback in response to a dispatched payload.
- **`waitFor(array<string> ids): void`**
Waits for the callbacks specified to be invoked before continuing execution of the current callback. This method should only be used by a callback in response to a dispatched payload.

- **dispatch(object payload): void** Dispatches a payload to all registered callbacks.
- **`dispatch(object payload): void`** Dispatches a payload to all registered callbacks.

- **isDispatching(): boolean** Is this Dispatcher currently dispatching.
- **`isDispatching(): boolean`** Is this Dispatcher currently dispatching.

## Example

For example, consider this hypothetical flight destination form, which
selects a default city when a country is selected:

```
```js
var flightDispatcher = new Dispatcher();

// Keeps track of which country is selected
Expand All @@ -52,7 +48,7 @@ var FlightPriceStore = {price: null};

When a user changes the selected city, we dispatch the payload:

```
```js
flightDispatcher.dispatch({
actionType: 'city-update',
selectedCity: 'paris'
Expand All @@ -61,7 +57,7 @@ flightDispatcher.dispatch({

This payload is digested by `CityStore`:

```
```js
flightDispatcher.register(function(payload) {
if (payload.actionType === 'city-update') {
CityStore.city = payload.selectedCity;
Expand All @@ -71,7 +67,7 @@ flightDispatcher.register(function(payload) {

When the user selects a country, we dispatch the payload:

```
```js
flightDispatcher.dispatch({
actionType: 'country-update',
selectedCountry: 'australia'
Expand All @@ -80,7 +76,7 @@ flightDispatcher.dispatch({

This payload is digested by both stores:

```
```js
CountryStore.dispatchToken = flightDispatcher.register(function(payload) {
if (payload.actionType === 'country-update') {
CountryStore.country = payload.selectedCountry;
Expand All @@ -93,7 +89,7 @@ to the returned token. Using this token with `waitFor()`, we can guarantee
that `CountryStore` is updated before the callback that updates `CityStore`
needs to query its data.

```
```js
CityStore.dispatchToken = flightDispatcher.register(function(payload) {
if (payload.actionType === 'country-update') {
// `CountryStore.country` may not be updated.
Expand All @@ -108,7 +104,7 @@ CityStore.dispatchToken = flightDispatcher.register(function(payload) {

The usage of `waitFor()` can be chained, for example:

```
```js
FlightPriceStore.dispatchToken =
flightDispatcher.register(function(payload) {
switch (payload.actionType) {
Expand Down