1

I've been learning about promises and observables recently. I found a lot of good information about the feature differences, but I was wondering if there were any performance / efficiency implications between promises and observables?

Note: I also looked through this post: Promise vs Observable but I didn't see any mention about efficiency.

bsheps
  • 1,438
  • 1
  • 15
  • 26

2 Answers2

0

There aren't any performance differences, they're just different paradigms for returning data as Promises return once but Observables return data like a stream.

jevenson
  • 164
  • 3
  • 5
  • Hey Joshin, thanks for the response. I didn't notice any real difference either when playing with test code, but I also couldn't find a way to isolate the method call from the async data. Do you have any reference or is it more so personal experience? – bsheps Oct 12 '18 at 02:41
0

Have you seen this post? It explains the differences pretty well.

You should look at it from a standpoint of --> "what's the best for my situation" rather than --> "which is more efficient".

Because they are both equally efficient depending on how you implement them.

Determine what is best depending on your use case. The end of this article in the "Which Approach Should You Use?" sums it up pretty well.

(example: if you are working with angular 2+ I would argue that for "efficiency" in that case would be observables, if not just to make your life easier);

richdurazo
  • 116
  • 5
  • Hey Rich, thanks for the reply. I understand the differences in how they work and why you might pick one; my question is asking specifically about efficiency in the sense of time to execute code. I can't find anything about efficiency anywhere (maybe it's irrelevant?) – bsheps Oct 12 '18 at 02:36
  • No Problem! I actually did quite a bit of searching yesterday and I could not find anything but I'll keep looking. Currently, I am trying to optimize an angular app as much as possible so its great to consider all performance implications. – richdurazo Oct 12 '18 at 16:50