I am able to run below code on node js as client. It works but when I use the same code in react-native it throws below error.
Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. 2019-05-14 13:47:57.271 [error][tid:com.facebook.react.JavaScript] 'Unhandled promise rejection', { [TypeError: _iterator[typeof Symbol === "function" ? typeof Symbol === "function" ? Symbol.iterator : "@@iterator" : "@@iterator"] is not a function. (In '_iteratortypeof Symbol === "function" ? typeof Symbol === "function" ? Symbol.iterator : "@@iterator" : "@@iterator"', '_iterator[typeof Symbol === "function" ? typeof Symbol === "function" ? Symbol.iterator : "@@iterator" : "@@iterator"]' is undefined)]
I tried adding below modules but none of them work
npm install --save @babel/polyfill es6 polyfill
import asyngularClient from 'asyngular-client';
let socket = asyngularClient.create({
port: 8000
});
(async () => {
let channel = socket.subscribe(inboxChannel, { customData: 'yiyiyi?' });
for await (let data of channel) {
// ... Handle channel data.
console.log('channel: ', inboxChannel, data);
const messages = [];
data.forEach(d => {
messages.unshift(d);
});
messages.forEach(m => {
console.log(m.content);
})
}
})();
actual output is an array of data.