Whether or not the return is required depends upon how the arrow function is declared. The right-hand side of an arrow function can be an expression or a brace-enclosed block of statements. When an expression is used, it’s evaluated and implicitly returned — no return is required:

const source = Observable.defer(() => Observable.of(42));

When a block is used, an explicit return is required:

const source = Observable.defer(() => {
return Observable.of(42);
});

For more information on arrow functions, see the MDN documentation.

RxJS core team member; front-end developer; mentor; speaker; open-source contributor

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store