Observable using defer

Subscribe to my newsletter and never miss my upcoming articles

Observable normally gets created once the code executes, Observable using defer , defers the creation of Observable. It waits till a subscription is done.

Below are main property of Observable using defer.

  1. Creates new observable every time on subscription
  2. No Observable is created until subscription

Below is the code showing Observable using defer

Here intentionally we are subscribing 2 times to show that each time Observable is created. You can also see that defer is taking fromIterable to create the observable. This will stop creating defer until we subscribe. Once subscribed Observable.fromInterable code will be invoked

No Comments Yet