Skip to content

Commit 523551a

Browse files
committed
Commented the example code.
1 parent 61f0a2a commit 523551a

File tree

14 files changed

+81
-3
lines changed

14 files changed

+81
-3
lines changed

flux/src/main/java/com/iluwatar/action/Action.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.iluwatar.action;
22

3-
3+
/**
4+
*
5+
* Action is the data payload dispatched to the stores when something happens.
6+
*
7+
*/
48
public abstract class Action {
59

610
private ActionType type;

flux/src/main/java/com/iluwatar/action/ActionType.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.iluwatar.action;
22

3+
/**
4+
*
5+
* Types of actions.
6+
*
7+
*/
38
public enum ActionType {
49

510
MENU_ITEM_SELECTED, CONTENT_CHANGED;

flux/src/main/java/com/iluwatar/action/Content.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.iluwatar.action;
22

3+
/**
4+
*
5+
* Content items.
6+
*
7+
*/
38
public enum Content {
49

510
PRODUCTS("Products - This page lists the company's products."), COMPANY("Company - This page displays information about the company.");

flux/src/main/java/com/iluwatar/action/ContentAction.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.iluwatar.action;
22

3-
3+
/**
4+
*
5+
* ContentAction is a concrete action.
6+
*
7+
*/
48
public class ContentAction extends Action {
59

610
private Content content;

flux/src/main/java/com/iluwatar/action/MenuAction.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package com.iluwatar.action;
22

33

4+
/**
5+
*
6+
* MenuAction is a concrete action.
7+
*
8+
*/
49
public class MenuAction extends Action {
510

611
private MenuItem menuItem;

flux/src/main/java/com/iluwatar/action/MenuItem.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.iluwatar.action;
22

3+
/**
4+
*
5+
* Menu items.
6+
*
7+
*/
38
public enum MenuItem {
49

510
HOME("Home"), PRODUCTS("Products"), COMPANY("Company");

flux/src/main/java/com/iluwatar/app/App.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,25 @@
77
import com.iluwatar.view.ContentView;
88
import com.iluwatar.view.MenuView;
99

10+
/**
11+
*
12+
* Flux is the application architecture that Facebook uses for building client-side web
13+
* applications. Flux eschews MVC in favor of a unidirectional data flow. When a user interacts with
14+
* a React view, the view propagates an action through a central dispatcher, to the various stores that
15+
* hold the application's data and business logic, which updates all of the views that are affected.
16+
*
17+
* This example has two views: menu and content. They represent typical main menu and content area of
18+
* a web page. When menu item is clicked it triggers events through the dispatcher. The events are
19+
* received and handled by the stores updating their data as needed. The stores then notify the views
20+
* that they should rerender themselves.
21+
*
22+
* http://facebook.github.io/flux/docs/overview.html
23+
*
24+
*/
1025
public class App {
1126

1227
public static void main( String[] args ) {
13-
// initialize
28+
// initialize and wire the system
1429
MenuStore menuStore = new MenuStore();
1530
Dispatcher.getInstance().registerStore(menuStore);
1631
ContentStore contentStore = new ContentStore();

flux/src/main/java/com/iluwatar/dispatcher/Dispatcher.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
import com.iluwatar.action.MenuItem;
1111
import com.iluwatar.store.Store;
1212

13+
/**
14+
*
15+
* Dispatcher sends Actions to registered Stores.
16+
*
17+
*/
1318
public class Dispatcher {
1419

1520
private static Dispatcher instance = new Dispatcher();

flux/src/main/java/com/iluwatar/store/ContentStore.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
import com.iluwatar.action.Content;
66
import com.iluwatar.action.ContentAction;
77

8+
/**
9+
*
10+
* ContentStore is a concrete store.
11+
*
12+
*/
813
public class ContentStore extends Store {
914

1015
private Content content = Content.PRODUCTS;

flux/src/main/java/com/iluwatar/store/MenuStore.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
import com.iluwatar.action.MenuAction;
66
import com.iluwatar.action.MenuItem;
77

8+
/**
9+
*
10+
* MenuStore is a concrete store.
11+
*
12+
*/
813
public class MenuStore extends Store {
914

1015
private MenuItem selected = MenuItem.HOME;

0 commit comments

Comments
 (0)