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
Example Error #13
Comments
The example is just meant to show how you use the methods individually and what they return. It assumes that people know about async. |
Wouldn't be better to use 2 different examples? just for better clarity. |
Both @sindresorhus, me and tons of authors are doing examples like this in many (small) modules. It's somewhat expected that users have some knowledge about how async works :). I.e, doing two async operations at the same time that depends on each other will mostly break. |
Agree with @kevva , no need to change it. |
Also, what if you expose more than two methods? To separate all those into their own examples would only clutter the documentation. |
If making more examples is a problem, simply by splitting the example code would show to a new user it is not meant to work with copy-paste: wallpaper.set('unicorn.jpg').then(() => {
console.log('done');
}); wallpaper.get().then(imagePath => {
console.log(imagePath);
//=> '/Users/sindresorhus/unicorn.jpg'
}); It is not a big deal, but it may make the example a little bit more clear to people who just want a first "Hello World" to try |
That's what I meant by cluttering the docs. |
well... it's one white line, but ok.It was just an idea |
Running your example:
On Linux Ubuntu throws an error on
/lib/linux.js
:Seems to be due to using async functions (get and set) at the same time (same problem with different error if using get before set
The problem solves simply using the second command inside the callback:
I'm not sure if the problem is just in linux, and if its an error in the example code or in the linux library.
The text was updated successfully, but these errors were encountered: