Rx.js 5 : why the scan use the function returned by map

时间:2016-09-21 05:47:45

标签: javascript rxjs5

Solved and Closed

The code snippet is from rx.js doc

var increaseButton = document.querySelector('#increase');
var increase = Rx.Observable.fromEvent(increaseButton, 'click')
  .map(() => state => Object.assign({}, state, {count: state.count + 1}));

// We create an object with our initial state. Whenever a new state change function
// is received we call it and pass the state. The new state is returned and
// ready to be changed again on the next click
var state = increase.scan((state, changeFn) => changeFn(state), {count: 0});

我在这里感到困惑,为什么changeFn是由map运营商返回的正确的?{/ p>

0 个答案:

没有答案