New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Var type. Closes #279. #511

Merged
merged 4 commits into from Jan 11, 2018

Conversation

Projects
None yet
2 participants
@cranst0n
Contributor

cranst0n commented Jan 10, 2018

No description provided.

@cranst0n

This comment has been minimized.

Contributor

cranst0n commented Jan 10, 2018

@alexandru First cut. Please advise if you want me to go more in depth with test/docs.

@codecov

This comment has been minimized.

codecov bot commented Jan 10, 2018

Codecov Report

Merging #511 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

@@            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
@alexandru

Thanks @cranst0n, some small changes needed — sorry about the formatting comments, it is now my intention to setup automatic code formatting, to avoid dragging PRs based on that (#513).

* 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]]

This comment has been minimized.

@alexandru

alexandru Jan 11, 2018

Member

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
// => 15

And 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)
}

This comment has been minimized.

@alexandru

alexandru Jan 11, 2018

Member

Get rid of blank line.

*/
final class Var[A] private (
initialValue: A
)(implicit scheduler: Scheduler)

This comment has been minimized.

@alexandru

alexandru Jan 11, 2018

Member

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] = {

This comment has been minimized.

@alexandru

alexandru Jan 11, 2018

Member

Similarly rename scheduler. Also initialValue => initial, since it's obvious it's a "value".

Sorry, personal pet peeve about redundant words in var names 😀

}
}

This comment has been minimized.

@alexandru

alexandru Jan 11, 2018

Member

Get rid of unneeded blank lines.

cranst0n and others added some commits Jan 11, 2018

@alexandru alexandru merged commit 7a3d8d0 into monix:master Jan 11, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment