Commit Graph

115 Commits (master)

Author SHA1 Message Date
Paolo Bonzini 1cbd5b2ca6 flatten: avoid early completion
The flatten operator currently calls onCompleted as soon as the
parent signals that it has completed.  However, there could be
more data incoming from the returned observables; in fact, the
flattened observable might even be infinite.

Track how many subscriptions are still active, and only call
onCompleted at the time of the last completion.
2020-01-14 17:24:33 +01:00
bjorn 355e14616e Formatting; 2019-10-20 14:43:33 -07:00
Bjorn 13a983787b
Merge pull request #45 from 4O4/observer-tests-improvements
Observer tests improvements
2019-10-20 14:40:26 -07:00
4O4 0f81a5640b Remove redundant whitespaces 2019-10-09 10:58:01 +02:00
4O4 fd7d8fb1d4 Fix custom lust paths 2019-10-09 10:49:52 +02:00
4O4 2388041ee0 Fix wrappers
Forgot to pass-through the params
2019-10-09 10:39:05 +02:00
4O4 0d1d147de2 Wrap spies with anonymous functions 2019-10-09 10:27:15 +02:00
4O4 b3442b838a Spy on public api instead of implementation details 2019-10-09 00:17:31 +02:00
4O4 c3afae67e0 Update lust to resolve problems from earlier versions 2019-10-09 00:17:06 +02:00
4O4 f5d29f7758 Improve Observer tests
Basically all tests are rewritten here. Implementation details should
not be checked because tests are becoming fragile when it comes to any
refactoring.

What instead should be tested is the actual **public behavior** of the
library when using its public interfaces.

While doing all these changes the following assumptions about this codebase
have been made:
 - class fields which are prefixed with underscore (like `observer._onNext`)
 are intended to be private and thus should only be accessed by members of
 the same class or its subclasses
 - `observer.stopped` is a public **readonly** field and should never be
 modified by the outside world, because its role is considered to be
 purely informational

If the above assumptions are not correct, this will need to be discussed
further. These improvements of the tests are necessary to introduce any
changes which include refactoring of the `Observer` in order to fix some
bugs.
2019-10-02 17:24:12 +02:00
4O4 f9c29e1f17 Add testing helpers for dealing with multiple errors 2019-10-02 17:11:52 +02:00
Daniel Andrus 4a475209f1 Add unsubscription test for zip operator 2019-05-07 10:48:47 -07:00
Junseong Jang f9ff630135 Add an assertion like 'expect(observable).to.produce.error()' to test 'onError'.
Fixed wrong test codes with the assertion.

Changed the behaviors of the following functions caused by argument types, to raise an error in the creation phase.

- Observable.defer
- Observable:buffer
- Observable:elementAt
- Observable:skipLast
- Observable:takeLast
- Observable:window
2019-03-28 03:04:58 +09:00
Junseong Jang a158200231 Fix `flatten` operator's subscription to unsubscribe from all sources
The `flatten` operator should unsubscribe from all flattened sources
2019-03-12 17:58:11 +09:00
Bjorn Swenson 687c7e53b4
Merge pull request #33 from naxxster/fix-merge-source-completed
Fix merge operator to handle onCompleted of input observables not a d…
2018-12-02 09:52:47 -08:00
Bjorn Swenson 66af07f13b
Merge pull request #32 from naxxster/fix-switch-subscription
Fix switch operator subscription to unsubscribe from inner subscription
2018-12-02 09:49:44 -08:00
Junseong Jang 5e4e857c96 Fix merge operator to handle onCompleted of input observables not a destructive way
The merge operator removed the source observable if it complete.
After that the subscriptions after that source observable index can not unsubscribe.
Fix the issue by recording the completed source index, as combineLatest operator does.
2018-11-28 17:20:41 +09:00
Junseong Jang 24450712be Fix switch operator subscription to unsubscribe from inner subscription
The switch operator should unsubscribe from inner subscribed source
2018-11-22 19:10:02 +09:00
Junseong Jang 8093dcbd21 Fix with operator subscription to unsubscribe from all sources
The with operator should unsubscribe from all subscribed sources
2018-11-20 14:35:07 +09:00
bjorn 6110f957ef Improve Observable.fromFileByLine test coverage; 2018-09-12 11:52:35 -07:00
bjorn 4962bdb523 Add tests for Observable.fromFileByLine; 2018-09-12 11:46:28 -07:00
Bjorn Swenson 34c8fee29a
Merge pull request #28 from naxxster/fix-combineLatest-unsubscribe-skip
Fix combineLatest operator subscription to unsubscribe from all subscription
2018-08-30 20:41:05 -07:00
Junseong Jang f1363ea5c5 Fix combineLatest operator subscription to unsubscribe from all subscription
If there is any nil subscription from sources,
the subscription skips to unsubscribe from the rest source's subscriptions.
2018-08-31 12:26:56 +09:00
Junseong Jang ff284ad215 Fix merge operator to produce a subscription. 2018-08-31 12:17:50 +09:00
xster 081b2cf55b Fix combineLatest to produce the subscription. 2018-05-17 17:25:11 +09:00
iTitou 20ec3b7bef [fix] Sample should not produce anything before the source has produced any value 2017-10-03 11:31:23 +02:00
bjorn f128b4844a Improve test coverage; 2017-06-24 13:03:56 -07:00
bjorn 611166ce36 Improve error tests; 2017-06-24 12:31:29 -07:00
bjorn a4337fecc6 Fix tests; 2017-05-25 16:20:37 -07:00
bjorn 166e61bb5e Avoid shared coroutines in Observable.fromCoroutine;
Currently, if a function is passed to Observable.fromCoroutine, a
coroutine is created and it is shared among all Observers.  Instead,
use a fresh coroutine for each Observer so all Observers receive the
same values.

When creating an Observable using an existing coroutine, this isn't
possible because the Observable is stateful (calling coroutine.resume
won't always yield the same values).
2017-03-21 21:13:54 -07:00
bjorn 4b0833d44e Rename fromValue to of; 2016-10-15 10:31:23 -07:00
bjorn 72a7b98cc3 Observable.sample; 2016-01-09 16:11:13 -08:00
bjorn 5f6d142f74 Safely execute user supplied code; 2015-11-16 20:48:56 -08:00
bjorn 007d9bce3d ReplaySubject; 2015-11-12 19:27:22 -08:00
bjorn 3fe1ee4e92 BehaviorSubject tests; 2015-11-12 19:08:48 -08:00
bjorn 49709f34e7 Test Subject; 2015-11-12 18:51:04 -08:00
bjorn dfcaaabe5d AsyncSubject; 2015-11-10 20:19:01 -08:00
bjorn e4cad53294 Observable.zip; 2015-11-09 22:19:44 -08:00
bjorn c0ddd8bc31 Fix Observable.skipLast alphabetization; 2015-11-07 15:54:34 -08:00
bjorn 94458ca44c Observable.takeLast; 2015-11-07 15:54:13 -08:00
bjorn 7ab40b5b3d Add Observable.switch test; 2015-11-07 15:51:54 -08:00
bjorn 5a27a2e8f0 Observable.switch; 2015-11-07 15:42:16 -08:00
bjorn b01c57ff5f Observable.skipLast; 2015-11-06 19:45:28 -08:00
bjorn 2bda006d14 Observable.startWith; 2015-11-05 19:31:48 -08:00
bjorn 3f75b68580 Observable.retry; 2015-11-05 19:19:32 -08:00
bjorn fc63946173 Observable.scan; 2015-11-05 18:42:07 -08:00
bjorn 3b3a298d02 Observable.replicate; 2015-11-05 18:16:45 -08:00
bjorn 00ac8afd6e Observable.ignoreElements; 2015-11-04 18:49:50 -08:00
bjorn 271e9ffda1 Observable.flatMapLatest; 2015-11-02 23:04:16 -08:00
bjorn 241c4062af Observable.elementAt; 2015-11-02 22:18:56 -08:00