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

Found some Syntax Errors #9

Open
Barathiraja opened this issue Jul 15, 2016 · 1 comment
Open

Found some Syntax Errors #9

Barathiraja opened this issue Jul 15, 2016 · 1 comment

Comments

@Barathiraja
Copy link

Hi,

I have Found Following Syntax Errors in the module.

First One:
conversationsClient.listen().then(clientConnected, function (error) {
look at the above line. here, the function clientConnected is called without parenthesis

and the Right way is
conversationsClient.listen().then( clientConnected() , function (error) {

Second One:
conversationsClient.inviteToConversation(inviteTo, options).then(conversationStarted, function (error) {

Here, the function conversationStarted is called without parenthesis, also parameter conversation is not passed

and the Right way is
conversationsClient.inviteToConversation(inviteTo, options).then(conversationStarted(conversationParameter), function (error) {

and I don't know what to pass as conversationParameter. If anyone knows, Please let me know.

@AbhinavMadahar
Copy link

Hey @Barathiraja I'm not a developer at Twilio, but I do have experience in JS. The code here is perfectly fine because, in JS, functions can be passed as variables without calling them.

listen().then wants a function to run after the conversationsClient starts listening. clientConnected is the function we want to run after we start listening, so we pass it without parens to the .then function. If we used the parens, we would evaluate clientConnected and then pass the output of that function to the .then method, but .then expects a function that it runs by itself.

It's the same for the second, except the .then method passes conversationsStarted the conversationsParameter automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants