Is it possible to create chained methods that are asynchronous like this in node.js
File.create('file.jpg').rename('renamed.jpg').append('Hello World')
That is to say non-blocking.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You basically want to abstract the asynchronous nature of the file-handling operations on your API.
It can be done, I would recommend you to give a look to the following article:
The article was written by Dustin Diaz, who currently works on the @anywhere JavaScript API, and he does exactly what you want, using a using a simple Queue implementation, a fluent interface can be created, being independent of any callback.
The asynchronicity is hidden and it is handled internally by your API, it’s a nice and simple technique.