( flux - chat example)
간단한 기능 추가
Q&A
- CreateThread
- ReceiveNewMessage
- ... ...
Action
Dispatch
Store
View
ReceiveAll
ChatAppDispatcher
MessageStore
RECEIVE_RAW_MESSAGES
ThreadStore
RECEIVE_RAW_MESSAGES
UnreadThreadStore
RECEIVE_RAW_MESSAGES
Text
MessageSection
ThreadSection
Action
Dispatch
Store
View
CreateMessage
ChatAppDispatcher
MessageStore
CREATE_MESSAGE
MessageSection
ThreadSection
Action
Dispatch
Store
View
ReceiveAll
ChatAppDispatcher
MessageStore
CLICK_THREAD
ThreadStore
CLICK_THREAD
UnreadThreadStore
CLICK_THREAD
MessageSection
ThreadSection
추후 폴더 /파일구성에 대한 Best Practice를 고려!!
Action
Dispatch
Store
View
CreateMessage
ChatAppDispatcher
MessageStore
CREATE_MESSAGE
MessageSection
ThreadSection
ChatAppDispatcher.dispatch({
type: ActionTypes.CREATE_MESSAGE,
text: text,
currentThreadID: currentThreadID
});
var message = ChatMessageUtils.getCreatedMessageData(text, currentThreadID);
ChatWebAPIUtils.createMessage(message);
case ActionTypes.CREATE_MESSAGE:
var message = ChatMessageUtils.getCreatedMessageData(
action.text,
action.currentThreadID
);
_messages[message.id] = message;
MessageStore.emitChange();
break;
(ChatConstant.js)
var keyMirror = require('keymirror');
module.exports = {
ActionTypes: keyMirror({
CLICK_THREAD: null,
CREATE_MESSAGE: null,
RECEIVE_RAW_CREATED_MESSAGE: null,
RECEIVE_RAW_MESSAGES: null
})
};
( CreateThread )