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

await connectToRemote() not returning a connection or error #18

Open
reggie3 opened this issue Jan 22, 2018 · 4 comments
Open

await connectToRemote() not returning a connection or error #18

reggie3 opened this issue Jan 22, 2018 · 4 comments

Comments

@reggie3
Copy link
Contributor

reggie3 commented Jan 22, 2018

The following code doesn't return a connection, nor does connectToRemote() return an error to be caught

 makeRemoteConnection = async () => {
    this.printElement('connecting to remote');
    try {
      let remote = await connectToRemote();
      this.remote = remote;
      this.printElement('remote connected');
      this.printElement(this.remote);
      this.bindListeners();

      // let the webview know we are listening
      this.printElement('emitting webview ready');
      this.remote.emit('WEBVIEW_READY', {
        payload: 'hello'
      });
      this.printElement('WEBVIEW_READY emitted');
    } catch (error) {
      console.log(`Error: ${error}`);
      this.printElement(`remote connect error ${error}`);
    }
  };

I receive the "connecting to remote" message, but I never receive the expected "remote connected" message. Additionally, no error is thrown for catching.

@lesnitsky
Copy link
Owner

Hey @reggie3, thanks for opening this up. I have 2 quick questions:

what version are you using?
is it webview side code or react-native? (if rn – you forgot to pass webview instance as a parameter to connectToRemote)
if this is webview side code – please drop me a sample of code being evaluated on react-native side

thanks

@reggie3
Copy link
Contributor Author

reggie3 commented Jan 22, 2018 via email

@lesnitsky
Copy link
Owner

lesnitsky commented Jan 22, 2018

Could you please provide react-native side code as well?

@reggie3
Copy link
Contributor Author

reggie3 commented Jan 23, 2018

Here it goes:

  componentDidMount() {
    console.log(`WebViewLeaflet INFO: connecting to remote`);

    connectToRemote(this.webview)
      .then(remote => {
        this.remote = remote;
        console.log(`WebViewLeaflet INFO: remote connected`);
        this.bindListeners();

        // attempt to send the map center coords in case the remote is 
        // connected after the webview is ready
        this.sendUpdatedMapCenterCoordsToHTML(this.props.mapCenterCoords);
      })
      .catch((error)=>{
        console.log(`WebViewLeaflet ERROR: ${error}`);
      });
    console.log('WebViewLeaflet INFO: wbvw braintree mounted');
  }

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