Skip to content
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

Scala Adaptor Details #512

Merged
merged 19 commits into from
Nov 26, 2013
Merged

Conversation

samuelgruetter
Copy link
Contributor

With #503, some files were lost, so I added them again, and I also fixed many other details. There are no changes in functionality/inheritance, only "cosmetics". Except samuelgruetter@8567fcb : @headinthebox could you please confirm this one-line change?

@benjchristensen
Copy link
Member

@headinthebox @samuelgruetter Please confirm the two of you agree on this and I'll merge.

@cloudbees-pull-request-builder

RxJava-pull-requests #437 SUCCESS
This pull request looks good

@headinthebox
Copy link
Contributor

Looks good.

@headinthebox
Copy link
Contributor

Found a small bug (copy & paste)

object PublishSubject {
def apply[T](value: T): PublishSubject[T] = {
new PublishSubjectT
}
}

We need to add as well (and have the above call this one). I use the above to force type inference

object PublishSubject {
def applyT: PublishSubject[T] = {
new PublishSubjectT
}
}

@samuelgruetter
Copy link
Contributor Author

2x exactly the same?
(btw please indent code by 4 spaces ;-) )

@samuelgruetter
Copy link
Contributor Author

@headinthebox I still don't understand what you mean with this comment

@headinthebox
Copy link
Contributor

This is a trick we often use in C#. You pass in a dummy "witness" of type T to help the compiler infer types. If you say PublishSubject() it will infer PublishSubject[Nothing] and you are forced tp write PublishSubjectT. I never want to write a concrete type anywhere.

@samuelgruetter
Copy link
Contributor Author

With the current code

object PublishSubject {
  def apply[T](): PublishSubject[T] = {
    new PublishSubject[T](rx.subjects.PublishSubject.create())
  }
}

we can do the following:

val s1 = PublishSubject[Int]() // inferred type of s1: PublishSubject[Int]
val s2 = PublishSubject()      // inferred type of s2: PublishSubject[Nothing]
val s3: PublishSubject[Int] = PublishSubject() // also works

What else do you want to be possible?

@samuelgruetter
Copy link
Contributor Author

So you want to write

val s4 = PublishSubject(0)

because you prefer writing 0 over writing Int?
That's never done in Scala and looks very weird to me...

benjchristensen added a commit that referenced this pull request Nov 26, 2013
@benjchristensen benjchristensen merged commit c2c382b into ReactiveX:master Nov 26, 2013
rickbw pushed a commit to rickbw/RxJava that referenced this pull request Jan 9, 2014
jihoonson pushed a commit to jihoonson/RxJava that referenced this pull request Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants