commit e5d810747bf716b300765c5fee28231032fb5673
parent 52802ef41d6912e7648e8bc92ebdf7b1c372d1b8
Author: Konstantin Tarkus <koistya@gmail.com>
Date: Mon, 17 Aug 2015 23:44:13 +0300
Merge pull request #215 from koistya/filenames
Rename core/dispatcher.js and core/location.js to use camelCase
Diffstat:
7 files changed, 66 insertions(+), 62 deletions(-)
diff --git a/src/app.js b/src/app.js
@@ -3,9 +3,9 @@
import 'babel/polyfill';
import ReactDOM from 'react-dom';
import FastClick from 'fastclick';
+import dispatcher from './core/dispatcher';
import router from './router';
-import Dispatcher from './core/Dispatcher';
-import Location from './core/Location';
+import location from './core/location';
import ActionTypes from './constants/ActionTypes';
const container = document.getElementById('app');
@@ -35,7 +35,7 @@ function run() {
});
});
- Dispatcher.register(action => {
+ dispatcher.register(action => {
if (action.type === ActionTypes.CHANGE_LOCATION) {
router.dispatch({ path: action.path, context }, (state, component) => {
ReactDOM.render(component, container);
@@ -45,7 +45,7 @@ function run() {
}
function handlePopState(event) {
- Location.navigateTo(window.location.pathname, { replace: !!event.state });
+ location.navigateTo(window.location.pathname, { replace: !!event.state });
}
// Run the application when both DOM is ready
diff --git a/src/core/Dispatcher.js b/src/core/Dispatcher.js
@@ -1,5 +0,0 @@
-/*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */
-
-import { Dispatcher } from 'flux';
-
-export default new Dispatcher();
diff --git a/src/core/Location.js b/src/core/Location.js
@@ -1,24 +0,0 @@
-/*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */
-
-import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';
-import Dispatcher from '../core/Dispatcher';
-import ActionTypes from '../constants/ActionTypes';
-
-export default {
-
- navigateTo(path, options) {
- if (canUseDOM) {
- if (options && options.replace) {
- window.history.replaceState({}, document.title, path);
- } else {
- window.history.pushState({}, document.title, path);
- }
- }
-
- Dispatcher.dispatch({
- type: ActionTypes.CHANGE_LOCATION,
- path
- });
- }
-
-};
diff --git a/src/core/dispatcher.js b/src/core/dispatcher.js
@@ -0,0 +1,7 @@
+/*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */
+
+import { Dispatcher } from 'flux';
+
+const dispatcher = new Dispatcher();
+
+export default dispatcher;
diff --git a/src/core/location.js b/src/core/location.js
@@ -0,0 +1,26 @@
+/*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */
+
+import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';
+import dispatcher from '../core/dispatcher';
+import ActionTypes from '../constants/ActionTypes';
+
+const location = {
+
+ navigateTo(path, options) {
+ if (canUseDOM) {
+ if (options && options.replace) {
+ window.history.replaceState({}, document.title, path);
+ } else {
+ window.history.pushState({}, document.title, path);
+ }
+ }
+
+ dispatcher.dispatch({
+ type: ActionTypes.CHANGE_LOCATION,
+ path
+ });
+ }
+
+};
+
+export default location;
diff --git a/src/utils/Link.js b/src/utils/Link.js
@@ -1,29 +0,0 @@
-/*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */
-
-import invariant from 'fbjs/lib/invariant';
-import Location from '../core/Location';
-
-function handleClick(event) {
-
- // If not left mouse click
- if (event.button !== 0) {
- return;
- }
-
- // If modified event
- if (event.metaKey || event.altKey || event.ctrlKey || event.shiftKey) {
- return;
- }
-
- var el = event.currentTarget;
-
- invariant(el && el.nodeName === 'A', 'The target element must be a link.');
-
- // Rebuild path
- var path = el.pathname + el.search + (el.hash || '');
-
- event.preventDefault();
- Location.navigateTo(path);
-}
-
-export default { handleClick };
diff --git a/src/utils/link.js b/src/utils/link.js
@@ -0,0 +1,29 @@
+/*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */
+
+import invariant from 'fbjs/lib/invariant';
+import location from '../core/location';
+
+function handleClick(event) {
+
+ // If not left mouse click
+ if (event.button !== 0) {
+ return;
+ }
+
+ // If modified event
+ if (event.metaKey || event.altKey || event.ctrlKey || event.shiftKey) {
+ return;
+ }
+
+ var el = event.currentTarget;
+
+ invariant(el && el.nodeName === 'A', 'The target element must be a link.');
+
+ // Rebuild path
+ var path = el.pathname + el.search + (el.hash || '');
+
+ event.preventDefault();
+ location.navigateTo(path);
+}
+
+export default { handleClick };