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

Use default arguments for default schedulers #40

Closed
samuelgruetter opened this issue Oct 8, 2014 · 5 comments
Closed

Use default arguments for default schedulers #40

samuelgruetter opened this issue Oct 8, 2014 · 5 comments
Assignees

Comments

@samuelgruetter
Copy link
Collaborator

Many methods have two versions: One without scheduler, which uses some default scheduler, and one which takes a scheduler provided by the user.

Example:

def takeRight(time: Duration): Observable[T]
def takeRight(time: Duration, scheduler: Scheduler): Observable[T]

Using Scala's default arguments, these two methods could be replaced by just one:

def takeRight(time: Duration, scheduler: Scheduler = ComputationScheduler()): Observable[T]

For users, this should not cause any breaking changes.

In addition to making the API much smaller, this also provides much better documentation: Just by looking at the signature, you know what the default scheduler is, whereas now, you have to read the documenation (which might be outdated) or even resort to reading the implementation.

This solution is less powerful than what I proposed in #16, but it's much easier to understand, and does not break any existing code. Also, since the Default Schedulers Plugin now provides support for custom default schedulers, there no need to solve this using implicits.

@headinthebox
Copy link
Contributor

I like default arguments (and I think implicit schedulers are too complicated).
What is nice about default parameters is that it is crystal clear what the scheduler is.
Lets do it.

@jbripley
Copy link
Contributor

jbripley commented Oct 8, 2014

I could take a look at this one.

@benjchristensen
Copy link
Member

That is a very nice Scala feature.

@zsxwing zsxwing self-assigned this Oct 9, 2014
@zsxwing
Copy link
Member

zsxwing commented Oct 9, 2014

Sorry that I assigned this one to myself by mistake. I planed to assign to @jbripley. However, looks I can only assign to people in ReactiveX.

jbripley pushed a commit to jbripley/RxScala that referenced this issue Oct 9, 2014
…g a default Scheduler

- Changes some methods to require parentheses (timestamp, timeInterval)

- Make CompletenessTest fail unit tests

Fixes ReactiveX#40 and ReactiveX#36
jbripley pushed a commit to jbripley/RxScala that referenced this issue Oct 11, 2014
…g a default Scheduler

- Changes some methods to require parentheses (timestamp, timeInterval)

- Make CompletenessTest fail unit tests

Fixes ReactiveX#40 and ReactiveX#36
@dhoepelman
Copy link
Collaborator

Due to project EOL status, this improvement will not be made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment