Files
freeCodeCamp/common/app/redux/actions.js

67 lines
1.7 KiB
JavaScript
Raw Normal View History

2016-04-24 21:54:48 -07:00
import { Observable } from 'rx';
2016-01-27 11:34:44 -08:00
import { createAction } from 'redux-actions';
import types from './types';
// updateTitle(title: String) => Action
export const updateTitle = createAction(types.updateTitle);
2016-02-04 15:03:05 -08:00
let id = 0;
2016-01-27 11:34:44 -08:00
// makeToast({ type?: String, message: String, title: String }) => Action
export const makeToast = createAction(
types.makeToast,
2016-02-04 15:03:05 -08:00
toast => {
id += 1;
return {
...toast,
id,
type: toast.type || 'info'
};
}
2016-01-27 11:34:44 -08:00
);
// fetchUser() => Action
// used in combination with fetch-user-saga
export const fetchUser = createAction(types.fetchUser);
// setUser(userInfo: Object) => Action
export const setUser = createAction(types.setUser);
// updatePoints(points: Number) => Action
export const updatePoints = createAction(types.updatePoints);
2016-03-02 22:19:04 -08:00
// hardGoTo(path: String) => Action
export const hardGoTo = createAction(types.hardGoTo);
2016-03-05 21:06:04 -08:00
export const initWindowHeight = createAction(types.initWindowHeight);
2016-03-05 21:06:04 -08:00
export const updateWindowHeight = createAction(types.updateWindowHeight);
export const updateNavHeight = createAction(types.updateNavHeight);
2016-03-10 17:21:46 -08:00
// data
export const updateChallengesData = createAction(types.updateChallengesData);
export const updateJobsData = createAction(types.updateJobsData);
export const updateHikesData = createAction(types.updateHikesData);
2016-04-24 21:54:48 -07:00
export const createErrorObservable = error => Observable.just({
2016-04-24 21:54:48 -07:00
type: types.handleError,
error
});
// drawers
export const toggleMapDrawer = createAction(
types.toggleMapDrawer,
e => e.preventDefault()
);
2016-06-03 23:34:28 -07:00
export const toggleWikiDrawer = createAction(types.toggleWikiDrawer);
// chat
export const toggleMainChat = createAction(
types.toggleMainChat,
e => {
if (!(e.ctrlKey || e.metaKey)) {
e.preventDefault();
}
}
);