When calling Observable.create, after running all the observer.next() calls, is it recommended to call observer.complete()
Can only be answered with "it depends". Generelly yes, if you know there won't be any more notifications it is good to inform your subscribers about that circumstance. You wouldn't like it if your favourite YouTuber stopped putting up videos without informing you about it.
However, complete
is more than just an information. It effectively closes your observable and thus prohibits you to send any more regular notifications. If you aren't sure if you might be sending notifications in the future, don't call complete
. Once called, tehre is no coming back.
Similarly, if we don't, does this method get automatically called?
No. You get a long-living Observable if you never call complete
.
And does code after the complete method get run as well?
Yes, but as mentioned, you cannot send any more notifications to your subscriber.
At this point I should probably make you aware of the Observable Contract. It's kind-of a tough read in my opinion (many unfamiliar terms), but needed to fully understand ReactiveX.