-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Phone book #23
base: master
Are you sure you want to change the base?
Phone book #23
Conversation
…g data from server.
… render name and phone from data recieved from server
|
||
<script src="src/users.js"></script> | ||
<script src="src/router.js"></script> | ||
<script src="src/server-api.js"></script> | ||
<!-- <script src="src/contacts.js"></script> --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's seems like an a duplication with line 20, please remove it
<script src="src/keypad.js"></script> | ||
<script src="src/edit-user.js"></script> | ||
<script src="src/user.js"></script> | ||
<!-- <script src="src/add-user.js"></script> --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what the status of that script? it's better to remove commented code. The commented code just makes discouraged the next developer who inspect such code
const fs = require('fs'); | ||
const port = 3000; | ||
|
||
http.createServer( (request, response) =>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally, you need your own server only for development purpose, so you could use some instruments like webpack-dev-server or so
class App { | ||
constructor(appContainerId) { | ||
this.state = {}; | ||
this.appContainer = document.getElementById(appContainerId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
appContainerId - not sure that variable should be dynamic, it's fine to make it static
|
||
renderAppContainer(){ | ||
return ` | ||
${this.renderAppHead()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's safe to store all HTML content inside the current method, no need additional abstraction.
I've been talked about additional methods when we've been used document.createElement in such situation abstraction could tell us more. But if you have just a plain HTML, no need an additional abstraction
const serverAPI = this.app.serverAPI; | ||
const updatingUser = serverAPI.updateUser(data); | ||
updatingUser.then( response => { | ||
this.app.pages.contacts.pageObject.users = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's breaking single responsibility principal an could causes unpredictable errors in future
const serverAPI = this.app.serverAPI; | ||
const addingUser = serverAPI.addUser(data); | ||
addingUser.then( response => { | ||
return response.json(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
return response.json(); | ||
}) | ||
.then(addedUser => { | ||
this.app.pages.contacts.pageObject.users = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's breaking single responsibility principal an could causes unpredictable errors in future
const serverAPI = this.app.serverAPI; | ||
const deletingUser = serverAPI.deleteUser(id); | ||
deletingUser.then( response => { | ||
this.app.pages.contacts.pageObject.users = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like really mess.
I believed pageObject is required overhead to structure, but it just makes the code more confusing.
If you want to store something you have to move its state and work with it directly.
If you want to update state - make 1 method where all updates would happens.
You could desing your app state withholding in mind 1 idea "I need to log my new state in console every time something changing"
const newPage = 'contacts'; | ||
const newState = { activePage : newPage }; | ||
this.app.updateState(newState); | ||
this.app.router.gotToPage(this.app.state); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well as I see it's not bad at all, but with problem in architecture
Основные функции работают.
Из того что я знаю точно не работает:
Вобще получилось очень сумбурно и я уверен что архитектур у к черту неправильная, но как его все связать правильно я не знаю...
MVC скорее всего тоже не получится.