voryx / thruway.js

RxJS WAMPv2 Client
MIT License
28 stars 13 forks source link

Registering async functions #23

Closed 27leaves closed 5 years ago

27leaves commented 5 years ago

In autobahnjs, I have the possibility to return a promise, and the function session.call will only be called when the promise resolves.

  async function add2(args, kwargs) {
    //await whatever, database calls etc
    return args[0] + args[1];
  }
  session.register('com.example.add2', add2);

In autobahn, it returns the result, in thruway it only returns an empty object. Is there a way to do this?

Thanks!

davidwdan commented 5 years ago

Can you install 2.0.0beta8 and try the following:


async function add2(a, b) {
  return  a + b;
}

wamp.register('add.rpc', add2).subscribe();
27leaves commented 5 years ago

Amazing! Quick fix as every time :) Thank you!