-
Notifications
You must be signed in to change notification settings - Fork 93
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
Asynchronous method implementations #9
Comments
Yes, I was thinking about this, but not sure what API would be best. Always use callbacks (and for simple synchronous handlers just end them with callback(data) instead of return(data)? Or have something like registerHandler and registerAsyncHandler? Can you think of ideal api for registering service for you with example? (provided that you need to tell in some way during registration method name, interface, object path, signature and implementation function reference. |
I have implemented my ideal API. :) It's not tested- I haven't gotten around to testing any of the node-dbus related code I've started- but will be testing it shortly, & will be validating these changes too. Thanks for the stunningly fast reply and your interest. Hopefully this is somewhat compatible with what you've been thinking and not ugly to you: apologies if it is. |
I like your approach but I don't want to depend on any promise/deferred library. I'l try to think of some solution. (otherwise your solution looks good btw) |
Hi @rektide ! I think I'm ready to look in this direction again, but I'd use bluebird library instead of Q |
I'll make the changeover this weekend. The timing here is wonderfuly humorously serendipitous- Thursday night I was back in action writing some experimental Generator based wrappers for node-dbus. Thanks for the fantastic library @sidorares. |
Hey pardon; follow-up here. I thought I had a codebase around that had this at least somewhat implemented, but either that didn't happen or it hasn't turned up! :/ I put in a little effort back in November to try and do the work, but wasn't bamboozling myself a bit/not finding a good-enough approach. Unknown when/if I'll get back to this issue. |
no problems :) |
Hi, function(cb) { ... } can be returned by handler function, then we can achieve async without changing func.apply in bus.js, Would like to see how it goes 🏭 |
Yeah, I looked at commits in your repo @luan007 |
👍 sounds great, would that be an upcoming feature on mainline repo? 🍊 |
I'd like to see it in main. Let's see where you are and shape api |
+1 on No external deps, function(cb) { } in handler function, where cb is in function cb(err, result) { } fasion, err is reflected directly to a dbus-error ( {name:.. message..} ) I wonder if those works for you, if it tastes OK i'll put some more work on error checking and so on |
I'm trying to multitask, can you please outline what we are doing here ( ideally with examples)? :) My understanding: when I'm exporting a function, currently wi create a mapping "name->implementation function ref" and on receiving invoke message do sync function call ( wrapped in try/catch so that we can send back error ). Proposed change: If function result is a function, treat it as a thunk and only send answer back when callback is called |
@luan007 this is mocha discussion on this topic - mochajs/mocha#329 Looks like there is no dependency on external promise library: if it's object with |
sorry for fuzzy replies, yes you're right that is the point 😺 |
yes, there should be proper dbus error object sent back when we process async function and it gives error result |
@luan007 Also if you can capture any information while you learn this library feel free to put into docs. What we have now in readme sucks :) |
Or, the node way? var handlerObj = {
someMethod: function(arg1, arg2, ..., cb) {
cb( .. );
}
}; What if everything is async? |
I see, var handlerObj = {
someMethod: function(){
return { then: function(cb){
cb( undefined, result );
} };
}
}; in mocha way |
well in user code real promise library is likely to be used, it's just we'll duck type test it to avoid dependency |
unfortunately i'm not into promise lib, need to dig in a bit.. |
Any progress on this stuff, @luan007 ? I'm also needing async calls. |
@tevaum @luan007 @rektide could you look at this - 290dbcb I'm using Note that co v4.x currently only works if there is global Promise. Not sure what to do with that, I'd like this dbus library to be compatible with node 0.8 - 0.12 for some time. One option is stick with v0.3.x |
Sorry for the absence, co looks great! |
:) completely forget what state is this at. If you are playing with async service methods right now - feel free to paste your examples here. These needs to be documented |
I'm interested to know if anyone has resolved this issue (at least partially) on any branch yet without depending on external libraries? If not I think I will give a shot at implementing it with native promises. |
Handlers currently must return their results immediately. Feature request: asynchronous execution.
The text was updated successfully, but these errors were encountered: