flux icon indicating copy to clipboard operation
flux copied to clipboard

ChatWebAPIUtils in the Chat example seems dirty

Open dcposch opened this issue 11 years ago • 2 comments

The Chat example does the following in the top level app.js :

ChatExampleData.init(); // load example data into localstorage

ChatWebAPIUtils.getAllMessages();
...

So getAllMessages() has side effects? Otherwise, why call it and throw away the result? That part doesn't seem clean.

dcposch avatar Mar 30 '15 00:03 dcposch

Just following the source... https://github.com/facebook/flux/blob/master/examples/flux-chat/js/utils/ChatWebAPIUtils.js#L29 https://github.com/facebook/flux/blob/master/examples/flux-chat/js/actions/ChatServerActionCreators.js#L20 ...looks like that's needed to initialize the stores with a dispatched action.

The server interaction is getting faked with local storage in the chat app. I wouldn't take it too seriously.

fisherwebdev avatar Mar 31 '15 05:03 fisherwebdev

why call getAllMessages on view ??

https://github.com/facebook/flux/blob/master/examples/flux-chat/js/app.js#L23

isn't better to have an action to do this??

victor-web avatar Jun 13 '16 14:06 victor-web