Conversation
Pull Request Test Coverage Report for Build 99
💛 - Coveralls |
*/ | ||
export const distinctValues = <T>() => | ||
distinctUntilChanged<T>((x, y) => { | ||
if (x instanceof BigNumber && y instanceof BigNumber) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see MikeMcl/bignumber.js#111
related: parity-js/ui#8 (comment)
It would be safer to use BigNumber.isBigNumber(x) && BigNumber.isBigNumber(y)
(https://mikemcl.github.io/bignumber.js/#isBigNumber)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right! Thanks, I'll change it asap
import { distinctValues } from './distinctValues'; | ||
|
||
// Observable that fires 2 times | ||
const fireTwice$ = () => concat(of(0), of(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't this be the same as () => of(0, 1);
?
.subscribe(() => { | ||
++numberOfTimesCalled; | ||
}); | ||
setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could use
.finalize(() => {
expect(numberOfTimesCalled).toEqual(1);
done();
}
* @param value - A value to test | ||
*/ | ||
const testValue = (value: any, type: string) => | ||
it('should only fire once for `type`', done => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe
`should only fire once for ${type}`
testValue({ foo: 'bar' }, 'object'); | ||
testValue(new BigNumber(2), 'BigNumber'); | ||
|
||
it('should only fire twice for difference values', done => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo different
fireTwice$().subscribe(() => { | ||
++numberOfTimesCalled; | ||
}); | ||
setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can also use finalize
here I think
So that RpcObservables don't fire again when the value didn't change.