Repository navigation
Add Var type. Closes #279. - #511
Conversation
|
@alexandru First cut. Please advise if you want me to go more in depth with test/docs. |
Codecov Report
@@ Coverage Diff @@
## master #511 +/- ##
==========================================
- Coverage 90.11% 90.09% -0.03%
==========================================
Files 359 360 +1
Lines 9380 9387 +7
Branches 1810 1810
==========================================
+ Hits 8453 8457 +4
- Misses 927 930 +3 |
| * or the `initialValue` (as the seed) in case no value has yet been emitted, then continuing | ||
| * to emit events subsequent to the time of invocation via an underlying [[ConcurrentSubject]]. | ||
| * | ||
| * @see [[ConcurrentSubject]] |
There was a problem hiding this comment.
I want a more detailed ScalaDoc with a sample preferably.
I'm thinking the sample should be like:
val a = Var(0)
val b = Var(0)
// Sum that gets re-calculated "reactively"
val sum = Observable.combineLatest(a, b)(_ + _)
// Subscribes for updates
sum.foreach(println)
a := 4
// => 4
b := 5
// => 9
a := 10
// => 15And it should include a mention that this is equivalent with a ConcurrentSubject.behavior(Unbounded) that caches the current value for immediate usage.
| value = update | ||
| underlying.onNext(update) | ||
| } | ||
|
|
| */ | ||
| final class Var[A] private ( | ||
| initialValue: A | ||
| )(implicit scheduler: Scheduler) |
There was a problem hiding this comment.
scheduler is too long, the type is more important here, just use s. And now definition fits on one line.
| /** Builder for [[Var]] */ | ||
| def apply[A]( | ||
| initialValue: A | ||
| )(implicit scheduler: Scheduler): Var[A] = { |
There was a problem hiding this comment.
Similarly rename scheduler. Also initialValue => initial, since it's obvious it's a "value".
Sorry, personal pet peeve about redundant words in var names 😀
| } | ||
|
|
||
| } | ||
|
|
There was a problem hiding this comment.
Get rid of unneeded blank lines.
No description provided.