-
Notifications
You must be signed in to change notification settings - Fork 8
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
Refactoring, API Layer, Vuex, README #9
Conversation
roma219
commented
Mar 21, 2018
•
edited
Loading
edited
- Added an API layer, which handles all the firebase communication (currently only Deliveries)
- Refactored actions to communicate with that API Layer instead of firebase db directly
- Refactored Components to use mapGetters and mapActions for getting state data & dispatching actions
- Changed router to pass params via props and added unknown page redirect
- Refactored a little according to vue style guide (component names etc) https://vuejs.org/v2/style-guide/
- Added info on style-guides (eslint & vue) to README
- Removed outdated info from README
- Separated connected components by folders
- Refactored mutations so they are in CAPITALS
- Added mutations for adding/saving/removing deliverie
- Converted deliveries from Array to Object for easier access (remove, edit)
- Added some pending buttons state to Delivery Form
we should probably get a more robust gitignore so every addition to the package.json doesn't result in 15000+ changes |
@nicksarafa Right, i'll add package-lock.json to .gitignore |
yeah list *.lock files inside the gitignore is considered a bad practice but it makes the pull requests annoying and unreadable. i propose we..
|
you can just collapse the .lock file when reading the PR. Don't add it to .gitignore, everyone needs to work with the same versions of stuff. |
also we decided to use yarn if I am not mistaken, so make the |
@piggydoughnut yeah we can do either or. I just prefer smaller pulls with an accurate count of changes in the log rather than 15,000 for every pull request pushed up |
@roma219 lot of cool stuff there, thanks! But I have some questions/comments: API Layer Routing Props Moment.js Changes from latest PR |
@JollyBrackets Compare:
and
If there is not gonna be a big number of firebase requests, we can use just a single api.js file for storing methods, don't need to specifically separate them into several files (like api/deliveries.js etc). Not sure what you mean by saying that "firebase can handle the state itself" - you mean actual vuex state or? For me right now seems from a vuex perfective it is just an endpoints to make regular asynchronous requests to. What do you think? vuex-router-sync Moment.js Changes from latest PR |
@JollyBrackets Yes sir that is what I was thinking of doing with async/await. Makes it a little cleaner and helps avoid callback hell :) I dig the API layer too. Do we just need to make a decision about Moment.js vs date-fns before approving the merge? Or is @roma219 still working to resolve conflicts from yesterdays PR? |
@roma219 cool, thanks for the answers. Here some more comments :) API Layer Vuex-Router-Sync Moment |
@JollyBrackets API Layer Still don't understand how can firebase data object "render components" reactively, you still need to make requests through it, don't you? Maybe we can settle with some other vuex modules accessing firebase directly and switch to API Layer structure later on if we feel like it's needed (or remove api layer completely if it feels non-needed later on)? |
@roma219 If I'm understanding @JollyBrackets correctly, every time one of the table components renders it fetches the relevant Firebase collection. So in practice Firebase is acting as a sort of 'remote' state store, so local state doesn't need to be passed as props through the router, or even kept in a vuex-store for that matter. We should probably even add a Firebase event listener for any database value changes, and then push any new values to the component so it updates the tables any time there is a change or addition: https://firebase.google.com/docs/database/admin/retrieve-data#section-event-types As for the API layer, if we can imagine this project ever needing one down the road, we might as well add it now, right? Otherwise as the project grows, it'll become more and more of a pain implementing it. |
@mediashane "every time one of the table components renders it fetches the relevant Firebase collection" - the question is, is this somehow automated and reactively changed, or you still basically make request in created() component callback to fetch the data and then store in in component's data to display it? Because this way it doesn't seem any different from any other restful api (which is how it is right now) |
@roma219 Yeah if I'm understanding everything correctly it is fundamentally RESTful. The request is made in created(), the response from Firebase is dispatched to the component's state store, and then the component updates to display that new state. We could automate this process by implementing a Firebase event listener like the one I linked above, so that the app's tables are updated in real time. Otherwise, as things are now, a user would have to make a navigation action in order to 'refresh' the contents of a screen (though admittedly this only really becomes an issue when we have more than one Banjar/Facility Manager using the app). |
@mediashane Well, this is how it is done now, but with a Vuex you separate view layer (vue components) and data logic (vuex store), so the requests are done in vuex actions, which update the state with a new data, and components just display it throught state getters. I don't see a problem with a potential implementaion of this firebase listeners, who would just call some vuex actions, who in response will fetch the new data etc. It just about the separation of concerns. |
@JollyBrackets @nicksarafa fixed the conflics & travis build |
@nicksarafa merge pls |