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

Give the initial action a special type #127

Merged
merged 1 commit into from
Jun 17, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/createDispatcher.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import composeMiddleware from './utils/composeMiddleware';

const INIT_ACTION = {
type: '@@INIT'
Copy link
Contributor

Choose a reason for hiding this comment

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

Camelcase would be sexier (example on MDN)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was actually kinda torn on this one. :-)
Action types are all caps by convention.

I'd rather keep @@ as the marker of “special stuff” and keep using all caps for action types and camel for state keys:

export const StateKeys = {
  LOG: '@@log'
};

export const ActionTypes = {
  JUMP_TO_STATE: '@@JUMP_TO_STATE'
};

};

export default function createDispatcher(store, middlewares = []) {
return function dispatcher(initialState, setState) {
let state = setState(store(initialState, {}));
let state = setState(store(initialState, INIT_ACTION));

function dispatch(action) {
state = setState(store(state, action));
Expand Down