Fundamentals only #7
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@nelsonic, after our yesterday's conversation, I've taken time to re-think the API call website and come up with a slightly more elegant solution than my previous one. In your messages you've suggested creating an issue discussing architectural ideas/decisions. However, I found it hard to theorise on that without trying to write some actual code to evaluate my ideas (and doing that I ended up proving some of them wrong). Instead, I wrote code with the challenges to overcome in mind. I thought that creating another pull request from a branch on my fork would be the easiest way to compare to the version pushed previously on codingforeveryone/MonkeyPhone and discuss the code.
Here are the issues I've identified and attempted to solve:
${Title}or${Snippet}so I can swap them when rendering queried content to the pagerenderSnippetfunction can now take a parameter of a number of snippets to generate and query parameter so it's going to be easier to implement things like pagination or user search queries later on.Problems I'm still facing:
jQuery.get()andjQuery.ajax(), I had to use callbacks so my code wouldn't try to render stuff before getting data from the server. To be able to go back and forth between main page and full article view, I needed to jump between callbacks and I ended up repeating main page button click handler 2 times. I tried to avoid that but didn't succeed in structuring the code without repeating that part twice. My initial idea was to place all event handlers in$(document).ready()but I had various problems returning control to that part (and deal with asynchronous functions at the same time) so I resorted to jumping between callbacks for content reloading instead.Anyway, I think that this version is an improvement on the last one. However, it's hard for me to evaluate if that's the right direction. I'd appreciate any feedback or direction before I start implementing stuff like pagination/routing/search queries based on user input etc.
Thanks!