develwoutacause’s avatardevelwoutacause’s Twitter Archive—№ 78

  1. #RxJS tip, prefer defer(() => getPromise()) over from(getPromise()). The former won't call getPromise() until the Observable is subscribed to, while the latter requires getPromise() to be called immediately.
    1. …in reply to @develwoutacause
      For example: If getPromise() calls some backend, using from() will send the HTTP request immediately, even if the resulting Observable is never subscribed to! defer() will wait to send the HTTP request until it's actually needed.