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

Fix issue #1187 and #1196 #1188

Merged
merged 3 commits into from
May 16, 2014
Merged

Conversation

zsxwing
Copy link
Member

@zsxwing zsxwing commented May 12, 2014

This PR fixed issue #1187.

Although using (action: => Unit) will require the following odd codes when somebody wants to use Function0 directly:

  @Test def schedulerExample5(): Unit = {
    val worker = IOScheduler().createWorker
    var no = 1
    val subscription = worker.schedule(new Function0[Unit]{
      def apply(): Unit = {
        println(s"Hello(${no}) from Scheduler")
        no += 1
        worker.schedule(apply(), 100 millis)
      }
    }.apply(), 1 seconds)
    TimeUnit.SECONDS.sleep(2)
    subscription.unsubscribe()
  }

I think people rarely use Function0 directly in Scala.

So I chose (action: => Unit) finally. schedulerExample4 is an more realistic example for recursive schedule.

This PR is a breaking change.

@zsxwing
Copy link
Member Author

zsxwing commented May 12, 2014

/cc @headinthebox @samuelgruetter

@headinthebox
Copy link
Contributor

Perhaps we should consider putting the "work" as the last (curried) argument.

worker.schedulePeriodically(
 {
   println(s"Hello(${no}) from Scheduler")
   no += 1
}, initialDelay = 1 seconds, period = 100 millis)

Would look very nice like this

worker.schedulePeriodically(initialDelay = 1 seconds, period = 100 millis){
   println(s"Hello(${no}) from Scheduler")
   no += 1
}

@cloudbees-pull-request-builder

RxJava-pull-requests #1098 FAILURE
Looks like there's a problem with this pull request

@cloudbees-pull-request-builder

RxJava-pull-requests #1099 FAILURE
Looks like there's a problem with this pull request

@zsxwing
Copy link
Member Author

zsxwing commented May 12, 2014

Yep. This Looks better.

@headinthebox
Copy link
Contributor

I always try to use that pattern with =>Unit.

@cloudbees-pull-request-builder

RxJava-pull-requests #1100 FAILURE
Looks like there's a problem with this pull request

@cloudbees-pull-request-builder

RxJava-pull-requests #1101 FAILURE
Looks like there's a problem with this pull request

@zsxwing zsxwing changed the title Fix issue #1187 Fix issue #1187 and #1196 May 13, 2014
@zsxwing
Copy link
Member Author

zsxwing commented May 13, 2014

Also fixed #1196 in this PR

@cloudbees-pull-request-builder

RxJava-pull-requests #1107 FAILURE
Looks like there's a problem with this pull request

@cloudbees-pull-request-builder

RxJava-pull-requests #1108 FAILURE
Looks like there's a problem with this pull request

benjchristensen added a commit that referenced this pull request May 16, 2014
@benjchristensen benjchristensen merged commit e53b1cd into ReactiveX:master May 16, 2014
@zsxwing zsxwing deleted the issue1187 branch May 16, 2014 05:00
@benjchristensen benjchristensen mentioned this pull request Jun 1, 2014
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