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

Cannot read property "find" of undefined react-native #14

Closed
octavonce opened this issue Feb 6, 2018 · 1 comment
Closed

Cannot read property "find" of undefined react-native #14

octavonce opened this issue Feb 6, 2018 · 1 comment

Comments

@octavonce
Copy link

octavonce commented Feb 6, 2018

Hello!

I am trying to set up subscriptions on a react-native app but i am receiving the following error:
screen shot 2018-02-06 at 16 49 00

This is the subscription handler which works perfectly on the web side:

const SubscriptionSocket = async (url, logger) => {
  const API_TOKEN = await AsyncStorage.getItem('API_TOKEN');

  return AbsintheSocket.create(
    new Socket(`${WS_URL}/socket`, {
      logger,
      params: { jwt: API_TOKEN }
    })
  );
}

function subscriptionHandler(subscriptionConfig, variables, cacheConfig, observer) {
  const socket = new SubscriptionSocket(WS_URL, (kind, msg, payload) => { 
    if (typeof payload !== 'undefined' && payload.subscriptionId) {
      observer.onNext({ data: payload.result.data });
    } else {
      if (process.env.NODE_ENV === 'development') {
        console.log(`${kind.toUpperCase()} ${msg}`, payload);
      }
    }
  });
  
  AbsintheSocket.send(socket, { operation: subscriptionConfig.text, variables });
  
  return { 
    dispose: () => socket.phoenixSocket.disconnect(() => {
      if (process.env.NODE_ENV === 'development') {
        console.log(`DISPOSE \n${subscriptionConfig.text}`);
      }
    })
  };
}

This is currently a blocker for us so any help would be appreciated.

@octavonce
Copy link
Author

I was returning a promise from the SubscriptionSocket constructor, sorry for posting the issue.

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

1 participant