Open nylen opened 7 years ago
Documentation will be provided once the script is complete. Code is not finalised at this time.
This sounds like a good idea to avoid duplicating work, but in practice this usually leads to documentation never being written. Also, code is never "complete", and the process of writing documentation often informs design improvements. (Similarly with unit tests, but that is another topic.)
After the next update I will start writing docmentation. Most likely only be for GET requests until authentication is figured out.
I have started to write the documentation using Slate. Nothing much at the moment. Just getting the structure ready.
https://seb86.github.io/WordPress-REST-API-jQuery-Documentation/
I think this project is small enough that the documentation could just live in the readme. In any case you want to avoid duplicating information. If you're using slate I guess you could replace the readme with a few sentences + a link to the documentation site? Though my opinion is still that it's not worth making users go to another site for documentation.
It's still not clear how to receive the results of an API call. Does restjQuery
accept a callback function? Return a promise? This should be documented and indicated in the examples.
I will provide clear examples soon.
When I make a call to an endpoint, how do I get the results?
I found the answer to this in the code rather than the documentation: this library uses async: false
, so when a request is made, the data is returned immediately.
You should change this as soon as possible to use promises and/or callbacks. Here's why:
Synchronous
XMLHttpRequest
outside of workers is in the process of being removed from the web platform as it has detrimental effects to the end user’s experience. (This is a long process that takes many years.) Developers must not passfalse
for theasync
argument when current global object is aWindow
object. User agents are strongly encouraged to warn about such usage in developer tools and may experiment with throwing anInvalidAccessError
exception when it occurs.
Yes I have been reading these types of topics to improve the library. I have little time at the moment to apply these improvements but will try to get it done soon. I am in the middle of writing the documentation currently.
For example: