-
Notifications
You must be signed in to change notification settings - Fork 158
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
Feature request: use node-style callbacks #124
Comments
Why break the API? |
No need to break the API, you can just use callback.length to continue to support the old callback style for backwards compatibility in addition to the node.js standard callback style (which is required e.g. to be able to use util.promisify). Note that only a few functions need this anyway. Most functions in bonescript (e.g. everything to do with gpio, pwm, and pinmux) are purely cpu-bound operations and using callbacks for them instead of using the synchronous versions accomplishes absolutely nothing besides making the code less efficient and harder to understand. Using callbacks for these should be entirely deprecated. |
This issue was moved to beagleboard#38 |
Currently bonescript uses value-only callbacks. I would like to make a feature request that uses node-style callbacks. This is the standard way that node uses callbacks.
I am glad to implement these changes. But I would like your approval / comments before continuing.
Below is some existing sample code from hw_mainline.js, it shows that the fs.readFile uses node-style callback, while bonescript converts this to a value-only callback.
Below I suggest a way to migrate to node-style callbacks. Since this is likely a breaking change for many applications I have built in a warning message. This method has the following features:
The difference is usage.
The text was updated successfully, but these errors were encountered: