tmijs / tmi.js

💬 Javascript library for the Twitch Messaging Interface. (Twitch.tv)
https://tmijs.com
MIT License
1.55k stars 214 forks source link

react-native compatibility #353

Closed ahmetabdi closed 5 years ago

ahmetabdi commented 5 years ago

https://github.com/tmijs/tmi.js/blob/master/lib/api.js

It would be great to have support for react-native in this file, currently it is falling back to the else statement and no document is found in react-native so it throws an error.

It seems like when I use the code in isExtension everything works fine, so would be nice to have a check in there too see if your using react-native and call that piece of code?

Actual behaviour:

document is not defined error is raised

Expected behaviour:

For api.js not to return an error

Error log:

ExceptionsManager.js:94 ReferenceError: document is not defined
    at client.api (api.js:49)
    at client._updateEmoteset (client.js:1252)
    at client.handleMessage (client.js:808)
    at client.js:1080
    at Array.forEach (<anonymous>)
    at client._onMessage (client.js:1079)
    at WebSocket.dispatchEvent (event-target-shim.js:818)
    at WebSocket.js:234
    at RCTDeviceEventEmitter.emit (EventEmitter.js:189)
    at MessageQueue.__callFunction (MessageQueue.js:395)

Server configuration

ahmetabdi commented 5 years ago

Fixed in PR :)