Skip to content
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

Adding AutobahnJS definition #3956

Merged
merged 1 commit into from Mar 29, 2015

Conversation

@darkl
Copy link
Contributor

darkl commented Mar 24, 2015

Type definitions for AutobahnJS.

@darkl darkl force-pushed the darkl:autobahnjs branch from 89723f1 to e1dfe0a Mar 24, 2015
@darkl darkl force-pushed the darkl:autobahnjs branch from e1dfe0a to c7cb3bc Mar 24, 2015
vvakame added a commit that referenced this pull request Mar 29, 2015
Adding AutobahnJS definition
@vvakame vvakame merged commit eb1de10 into DefinitelyTyped:master Mar 29, 2015
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@vvakame

This comment has been minimized.

Copy link
Member

vvakame commented Mar 29, 2015

@darkl thanks mate!

@bradws

This comment has been minimized.

Copy link

bradws commented on c7cb3bc Jun 13, 2016

I think there is a problem with the test here in file autobahn-tests.ts

The method add2(...) seems to be unable to reference the variable add2Count.

i.e. you can't do:

    add2(args: Array<number>): number {
        //return args[0] + args[1];                     // This works just fine
        return args[0] + args[1] + this.add2Count;      // This returns 'null' because it cant see 'this.add2Count'
    }

In a normal Typescript function call like the one above, the function is able to reference the this.add2Count variable when calling the add2(...) function. However since this particular function is being 'registered' with Autobahn, when the function executes, it can't (for some reason-is it a Typescript or Autobahn thing?) see anything 'outside' the function.

Is it possible to allow registered Autobahn/WAMP functions to reference variables outside the function yet inside a class like this - is there a particular pattern one can use? Can you provide a test like this?

This comment has been minimized.

Copy link
Contributor Author

darkl replied Jun 13, 2016

@bradws you are right that this is not bound. Replace registration line with this line:

        // 3) register a procedure for remoting
        session.register('com.myapp.add2', myInstance.add2.bind(myInstance));

This comment has been minimized.

Copy link

bradws replied Jun 13, 2016

@darkl Oh that's working now thanks! What is this 'bind' method - javascript/typescript/autobahn ??

This comment has been minimized.

Copy link
Contributor Author

darkl replied Jun 13, 2016

@bradws, Javascript method. Binds the method with this argument and (optionally) with other method arguments (so you don't have to specify them every call).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.