Open HoukasaurusRex opened 4 years ago
This is a good proposal. A special case I'd like to point out is for dynamic module imports.
do
const Streamer =(await import('@akkadu/rtc-streamer-consumer')).default
const streamer = new Streamer(streamerConfig)
// some other functions that need to await for streamer to be intialized
don't
this.streamer = await import('@akkadu/rtc-streamer-consumer')
.then(({ default: Streamer }) => new Streamer(this.streamerConfig))
this.initializeStreamerListeners()
this.subscribeToChannels()
// nor
let streamer
import('@akkadu/rtc-streamer-consumer')
.then(({ default: Streamer }) => {
const streamer = new Streamer(streamerConfig)
return streamer
})
.then((streamer) => {
// other functions that need to wait for streamer to initialize
})
do
don't