Reactive-Extensions / RxJS

The Reactive Extensions for JavaScript
http://reactivex.io
Other
19.48k stars 2.1k forks source link

Consider ES2015 Arrow Functions for Examples #1048

Open knpwrs opened 9 years ago

knpwrs commented 9 years ago

For example, the following:

/* Get stock data somehow */
var source = getStockData();

source
  .filter(function (quote) {
      return quote.price > 30;
  })
  .map(function (quote) {
      return quote.price;
  })
  .forEach(function (price) {
    console.log('Prices higher than $30: $' + price);
  });

Could be expressed as such:

// Get stock data somehow
var source = getStockData();

source
  .filter(quote => quote.price > 30)
  .map(quote => quote.price)
  .forEach(price => console.log(`Prices higher than $30: $${price}`));

Or even:

// Get stock data somehow
var source = getStockData();

source
  .filter(({price}) => price > 30)
  .forEach(({price}) => console.log(`Prices higher than $30: $${price}`));

Compatibility (Arrow Functions):

image

mattpodwysocki commented 8 years ago

@knpwrs fixed the front page at the very least.