debounce-vs-throttle

https://redd.one/blog/debounce-vs-throttle

用动画的形式给出了差别的描述。

文字上来说, debounce 

Discard emitted values that take less than the specified time, based on selector function, between output.

而  throttle

Emit value on the leading edge of an interval, but suppress new values until durationSelector has completed.

所以对某个时间段参数, 用throttle会保证一次发生(不会多), 而debounce不能保证发生。

 

 

trap in testing angular observable

https://medium.com/angular-in-depth/how-to-test-observables-a00038c7faad

excerpt:

The “subscribe and assert pattern” has the following downsides

  • You need to remind yourself always to call the done callback

    1. Don’t forget to call “done” when you’re done ☝️

    Often, tests which use the “subscribe and assert pattern” are green even though, in reality, they are failing. How come? 🤔

    In asynchronous scenarios, our test rushes through without also checking our assertions inside our nextcomplete or error handler. This can quickly happen if we forget to call the done callback after the assertions.

    The done callback is a way to indicate to the testing framework when our test is actually done.

    remarks: forgetting about “done” is elusive because this test passed when it actually failed. However, the karma will return and show you some other test failed if you run ng test. but the other test is actually passing. ng test is not good at reporting precisely.