Vulcan/packages/example-forum/lib/modules/posts/redux.js
2017-09-04 18:37:21 +09:00

29 lines
390 B
JavaScript

/*
Redux
*/
import { addAction, addReducer } from 'meteor/vulcan:core';
addAction({
postsViewed: {
setViewed: (postId) => ({
type: 'SET_VIEWED',
postId,
}),
},
});
addReducer({
postsViewed: (state = [], action) => {
if (action.type === 'SET_VIEWED') {
return [
...state,
action.postId,
];
}
return state;
},
});