|
@@ -1,3 +1,6 @@
|
|
|
+const ADD_POST = 'ADD-POST';
|
|
|
+const UPDATE_NEW_POST_TEXT = 'UPDATE-NEW-POST-TEXT';
|
|
|
+
|
|
|
let store = {
|
|
|
_state: {
|
|
|
profilePage: {
|
|
@@ -31,7 +34,7 @@ let store = {
|
|
|
this._callSubscriber = observer;
|
|
|
},
|
|
|
dispatch(action) {
|
|
|
- if (action.type === 'ADD-POST') {
|
|
|
+ if (action.type === ADD_POST) {
|
|
|
let newPost = {
|
|
|
id: 5,
|
|
|
message: this._state.profilePage.newPostText,
|
|
@@ -40,11 +43,20 @@ let store = {
|
|
|
this._state.profilePage.post.push(newPost);
|
|
|
this._state.profilePage.newPostText = "";
|
|
|
this._callSubscriber(this._state);
|
|
|
- } else if(action.type === 'UPDATE-NEW-POST-TEXT') {
|
|
|
+ } else if(action.type === UPDATE_NEW_POST_TEXT) {
|
|
|
this._state.profilePage.newPostText = action.newText;
|
|
|
this._callSubscriber(this._state);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+export const addPostActionCreator = () => ({ type: 'ADD-POST' });
|
|
|
+
|
|
|
+export const updateNewPostTextActionCreator = () {
|
|
|
+ return {
|
|
|
+ type: 'UPDATE-NEW-POST-TEXT',
|
|
|
+ newText: text
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
export default store;
|