xBytez / slackbotapi

node.js Slack RTM API module
GNU Lesser General Public License v3.0
136 stars 40 forks source link

Constructor does asynchronous tasks #51

Open fontanierh opened 8 years ago

fontanierh commented 8 years ago

The constructor performs asynchronous request to the Slack rtm.start method. The getChannel method of this module relies on the information gathered from this request and may fail when called right after construction.

SimonJang commented 4 years ago

What is the desired behavior here? Asynchronous behavior in constructor is undesired in my opinion. Perhaps there needs to be a .init() or .connect() method that covers the asynchronous behavior of the constructor? This is breaking change though.

The methods relying on the data from the constructor could also throw an error when the data is still undefined. This could be retried at some point in the future.