Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
83f1e56
Removed spurious package
AppliedDuality Nov 29, 2013
1949c42
Moved Subscription object to package rx.lang.scala.subscriptions with…
AppliedDuality Nov 29, 2013
3f844a8
Added immediate scheduler
AppliedDuality Nov 29, 2013
65c92bd
Added new thread scheduler
AppliedDuality Nov 29, 2013
e62cd3f
Added current thread scheduler
AppliedDuality Nov 29, 2013
3ad450c
Added ExecutorScheduler
AppliedDuality Nov 29, 2013
188ae7d
Added ScheduledExecutorServiceScheduler
AppliedDuality Nov 29, 2013
451f517
Added ThreadPoolForComputationScheduler
AppliedDuality Nov 29, 2013
4c23697
Added ThreadPoolForIOScheduler
AppliedDuality Nov 29, 2013
4f44f6e
Deleted old scheduler factory methods.
AppliedDuality Nov 29, 2013
54271d0
Deleted old Schedulers object.
AppliedDuality Nov 29, 2013
04a3ed3
Deleted spurious package object.
AppliedDuality Nov 29, 2013
ced58c8
Added TestScheduler
AppliedDuality Nov 29, 2013
0d00f26
Deleted spurious package object
AppliedDuality Nov 29, 2013
93073e2
Moved stuff around.
AppliedDuality Nov 29, 2013
b579835
Moved stuff around some more.
AppliedDuality Nov 29, 2013
ca2ce54
Fixed doc comment.
AppliedDuality Nov 29, 2013
180cebf
Removed dead function, left package object for scala docs.
AppliedDuality Nov 29, 2013
deebc0e
Made Subscription.app(rx.Subscription) private.
AppliedDuality Nov 29, 2013
4f34376
Added package names in doc comments to keep IntelliJ happy
AppliedDuality Nov 29, 2013
0ee0eb8
Factory methods for Observer.
AppliedDuality Nov 29, 2013
3a61819
Added copyright headers
AppliedDuality Nov 29, 2013
fc8ea03
Added copyright headers
AppliedDuality Nov 29, 2013
02ff7f7
Fixed ambigous definitions; kuddos to https://class.coursera.org/reac…
AppliedDuality Nov 29, 2013
096cb0b
Fixed type errors in Schedulers.
AppliedDuality Nov 30, 2013
0009925
Fixed implicit conversions to make compile work
AppliedDuality Nov 30, 2013
8ac60d9
Fixing tests
AppliedDuality Nov 30, 2013
eaa0de0
Fixing tests
AppliedDuality Nov 30, 2013
cbae35d
restore original gradlew
samuelgruetter Nov 30, 2013
baebd8c
add one missing import
samuelgruetter Nov 30, 2013
4fbb4ef
deleting def observable[T](=>T) requires deleting corresponding demo,…
samuelgruetter Nov 30, 2013
4f9105d
reorg imports of ImplicitFunctionConversions
samuelgruetter Nov 30, 2013
24e0baf
make zip with selector function private because
samuelgruetter Nov 30, 2013
3152d0e
scaladoc links in ThreadPoolForXxxScheduler
samuelgruetter Nov 30, 2013
ece590c
scaladoc for package rx.lang.scala
samuelgruetter Nov 30, 2013
766847f
restore subjects package object for scaladoc
samuelgruetter Nov 30, 2013
ea3894a
Merge pull request #1 from samuelgruetter/RxJavaBugFixesSam
headinthebox Nov 30, 2013
99a1d03
Pulled in changes from Samuel.
AppliedDuality Nov 30, 2013
25ce82f
Added Observable.create.
AppliedDuality Nov 30, 2013
5805deb
Double negation Observer.
AppliedDuality Dec 1, 2013
f699cd4
Made subjects safe
AppliedDuality Dec 1, 2013
4023679
Trivial code movements
AppliedDuality Dec 1, 2013
227e514
IntelliJ suggested style changes.
AppliedDuality Dec 2, 2013
38d4371
undo commit 99a1d035233100e32050240472a9bdc85521bc61
samuelgruetter Dec 4, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Moved stuff around.
  • Loading branch information
AppliedDuality committed Nov 29, 2013
commit 93073e26279b7e659b71a4d090f3cd64469e8029
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import rx.util.functions._
import scala.collection.Seq
import java.{lang => jlang}
import scala.language.implicitConversions
import rx.lang.scala.concurrency.Scheduler

/**
* These function conversions convert between Scala functions and Rx `Func`s and `Action`s.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package rx.lang.scala

import rx.util.functions.FuncN
import rx.Observable.OnSubscribeFunc
import rx.lang.scala.concurrency.Scheduler

/**
* The Observable interface that implements the Reactive Pattern.
Expand All @@ -44,7 +45,7 @@ import rx.Observable.OnSubscribeFunc
* @define subscribeObserverParamObserver
* the observer
* @define subscribeObserverParamScheduler
* the [[rx.lang.scala.Scheduler]] on which Observers subscribe to the Observable
* the [[Scheduler]] on which Observers subscribe to the Observable
* @define subscribeAllReturn
* a [[rx.lang.scala.Subscription]] reference whose `unsubscribe` method can be called to stop receiving items
* before the Observable has finished sending them
Expand Down Expand Up @@ -402,7 +403,7 @@ trait Observable[+T]
* The period of time each buffer is collecting values before it should be emitted, and
* replaced with a new buffer.
* @param scheduler
* The [[rx.lang.scala.Scheduler]] to use when determining the end and start of a buffer.
* The [[Scheduler]] to use when determining the end and start of a buffer.
* @return
* An [[rx.lang.scala.Observable]] which produces connected non-overlapping buffers with a fixed duration.
*/
Expand Down Expand Up @@ -443,7 +444,7 @@ trait Observable[+T]
* @param count
* The maximum size of each buffer before it should be emitted.
* @param scheduler
* The [[rx.lang.scala.Scheduler]] to use when determining the end and start of a buffer.
* The [[Scheduler]] to use when determining the end and start of a buffer.
* @return
* An [[rx.lang.scala.Observable]] which produces connected non-overlapping buffers which are emitted after
* a fixed duration or when the buffer has reached maximum capacity (which ever occurs first).
Expand Down Expand Up @@ -486,7 +487,7 @@ trait Observable[+T]
* @param timeshift
* The period of time after which a new buffer will be created.
* @param scheduler
* The [[rx.lang.scala.Scheduler]] to use when determining the end and start of a buffer.
* The [[Scheduler]] to use when determining the end and start of a buffer.
* @return
* An [[rx.lang.scala.Observable]] which produces new buffers periodically, and these are emitted after
* a fixed timespan has elapsed.
Expand Down Expand Up @@ -607,7 +608,7 @@ trait Observable[+T]
* The period of time each window is collecting values before it should be emitted, and
* replaced with a new window.
* @param scheduler
* The [[rx.lang.scala.Scheduler]] to use when determining the end and start of a window.
* The [[Scheduler]] to use when determining the end and start of a window.
* @return
* An [[rx.lang.scala.Observable]] which produces connected non-overlapping windows with a fixed duration.
*/
Expand Down Expand Up @@ -648,7 +649,7 @@ trait Observable[+T]
* @param count
* The maximum size of each window before it should be emitted.
* @param scheduler
* The [[rx.lang.scala.Scheduler]] to use when determining the end and start of a window.
* The [[Scheduler]] to use when determining the end and start of a window.
* @return
* An [[rx.lang.scala.Observable]] which produces connected non-overlapping windows which are emitted after
* a fixed duration or when the window has reached maximum capacity (which ever occurs first).
Expand Down Expand Up @@ -691,7 +692,7 @@ trait Observable[+T]
* @param timeshift
* The period of time after which a new window will be created.
* @param scheduler
* The [[rx.lang.scala.Scheduler]] to use when determining the end and start of a window.
* The [[Scheduler]] to use when determining the end and start of a window.
* @return
* An [[rx.lang.scala.Observable]] which produces new windows periodically, and these are emitted after
* a fixed timespan has elapsed.
Expand Down Expand Up @@ -782,28 +783,28 @@ trait Observable[+T]
}

/**
* Asynchronously subscribes and unsubscribes Observers on the specified [[rx.lang.scala.Scheduler]].
* Asynchronously subscribes and unsubscribes Observers on the specified [[Scheduler]].
*
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/subscribeOn.png">
*
* @param scheduler
* the [[rx.lang.scala.Scheduler]] to perform subscription and unsubscription actions on
* the [[Scheduler]] to perform subscription and unsubscription actions on
* @return the source Observable modified so that its subscriptions and unsubscriptions happen
* on the specified [[rx.lang.scala.Scheduler]]
* on the specified [[Scheduler]]
*/
def subscribeOn(scheduler: Scheduler): Observable[T] = {
Observable[T](asJavaObservable.subscribeOn(scheduler))
}

/**
* Asynchronously notify [[rx.lang.scala.Observer]]s on the specified [[rx.lang.scala.Scheduler]].
* Asynchronously notify [[rx.lang.scala.Observer]]s on the specified [[Scheduler]].
*
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/observeOn.png">
*
* @param scheduler
* the [[rx.lang.scala.Scheduler]] to notify [[rx.lang.scala.Observer]]s on
* the [[Scheduler]] to notify [[rx.lang.scala.Observer]]s on
* @return the source Observable modified so that its [[rx.lang.scala.Observer]]s are notified on the
* specified [[rx.lang.scala.Scheduler]]
* specified [[Scheduler]]
*/
def observeOn(scheduler: Scheduler): Observable[T] = {
Observable[T](asJavaObservable.observeOn(scheduler))
Expand Down Expand Up @@ -1081,7 +1082,7 @@ trait Observable[+T]
*
* @param duration the sampling rate
* @param scheduler
* the [[rx.lang.scala.Scheduler]] to use when sampling
* the [[Scheduler]] to use when sampling
* @return an Observable that emits the results of sampling the items emitted by the source
* Observable at the specified time interval
*/
Expand Down Expand Up @@ -1459,7 +1460,7 @@ trait Observable[+T]
* @param timeout
* The time each value has to be 'the most recent' of the [[rx.lang.scala.Observable]] to ensure that it's not dropped.
* @param scheduler
* The [[rx.lang.scala.Scheduler]] to use internally to manage the timers which handle timeout for each event.
* The [[Scheduler]] to use internally to manage the timers which handle timeout for each event.
* @return Observable which performs the throttle operation.
* @see `Observable.throttleWithTimeout`
*/
Expand All @@ -1477,7 +1478,7 @@ trait Observable[+T]
* @param timeout
* The time each value has to be 'the most recent' of the [[rx.lang.scala.Observable]] to ensure that it's not dropped.
* @param scheduler
* The [[rx.lang.scala.Scheduler]] to use internally to manage the timers which handle timeout for each event.
* The [[Scheduler]] to use internally to manage the timers which handle timeout for each event.
* @return Observable which performs the throttle operation.
* @see `Observable.debounce`
*/
Expand All @@ -1495,7 +1496,7 @@ trait Observable[+T]
* @param skipDuration
* Time to wait before sending another value after emitting last value.
* @param scheduler
* The [[rx.lang.scala.Scheduler]] to use internally to manage the timers which handle timeout for each event.
* The [[Scheduler]] to use internally to manage the timers which handle timeout for each event.
* @return Observable which performs the throttle operation.
*/
def throttleFirst(skipDuration: Duration, scheduler: Scheduler): Observable[T] = {
Expand Down Expand Up @@ -1768,11 +1769,11 @@ trait Observable[+T]
/**
* Perform work in parallel by sharding an `Observable[T]` on a
* [[rx.lang.scala.concurrency.Schedulers.threadPoolForComputation computation]]
* [[rx.lang.scala.Scheduler]] and return an `Observable[R]` with the output.
* [[Scheduler]] and return an `Observable[R]` with the output.
*
* @param f
* a function that applies Observable operators to `Observable[T]` in parallel and returns an `Observable[R]`
* @return an Observable with the output of the function executed on a [[rx.lang.scala.Scheduler]]
* @return an Observable with the output of the function executed on a [[Scheduler]]
*/
def parallel[R](f: Observable[T] => Observable[R]): Observable[R] = {
val fJava: Func1[rx.Observable[T], rx.Observable[R]] =
Expand All @@ -1781,13 +1782,13 @@ trait Observable[+T]
}

/**
* Perform work in parallel by sharding an `Observable[T]` on a [[rx.lang.scala.Scheduler]] and return an `Observable[R]` with the output.
* Perform work in parallel by sharding an `Observable[T]` on a [[Scheduler]] and return an `Observable[R]` with the output.
*
* @param f
* a function that applies Observable operators to `Observable[T]` in parallel and returns an `Observable[R]`
* @param scheduler
* a [[rx.lang.scala.Scheduler]] to perform the work on.
* @return an Observable with the output of the function executed on a [[rx.lang.scala.Scheduler]]
* a [[Scheduler]] to perform the work on.
* @return an Observable with the output of the function executed on a [[Scheduler]]
*/
def parallel[R](f: Observable[T] => Observable[R], scheduler: Scheduler): Observable[R] = {
val fJava: Func1[rx.Observable[T], rx.Observable[R]] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ package rx.lang.scala

import java.util.Date
import scala.concurrent.duration.Duration
import ImplicitFunctionConversions.scalaFunction0ProducingUnitToAction0
import ImplicitFunctionConversions.schedulerActionToFunc2
import rx.util.functions.{Action0, Action1, Func2}

/**
* Represents an object thatimport rx.lang.scala.ImplicitFunctionConversions
* Represents an object rx.lang.scala.ImplicitFunctionConversions
schedules units of work.
*/
trait Scheduler {
Expand All @@ -34,7 +32,7 @@ trait Scheduler {
* @param action Action to schedule.
* @return a subscription to be able to unsubscribe from action.
*/
def schedule(action: rx.lang.scala.Scheduler => Subscription): Subscription = {
def schedule(action: Scheduler => Subscription): Subscription = {
this.schedule[Integer](0, (s: Scheduler, x: Integer) => action(s): Subscription): Subscription
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package rx.lang.scala.concurrency

import java.util.concurrent.Executor
import rx.lang.scala.Scheduler
import java.util.concurrent.{ScheduledExecutorService, Executor}

object ExecutorScheduler {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package rx.lang.scala.concurrency

import rx.lang.scala.Scheduler
import java.util.concurrent.Executor

object NewThreadScheduler {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package rx.lang.scala.concurrency

import rx.lang.scala.Scheduler
import java.util.concurrent.ScheduledExecutorService
import scala.concurrent.duration.Duration
import rx.lang.scala.Scheduler

object ScheduledExecutorServiceScheduler {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package rx.lang.scala.concurrency

import rx.lang.scala.Scheduler
import scala.concurrent.duration.Duration
import rx.lang.scala.Scheduler

/**
* Provides constructors for `TestScheduler`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package rx.lang

import java.util.concurrent.TimeUnit
import java.util.Date
import rx.lang.scala.concurrency.Scheduler

/**
* This package contains all classes that RxScala users need.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@
package rx.lang.scala.subscriptions

/**
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package rx.lang.scala

/**
* Subscriptions are returned from all `Observable.subscribe` methods to allow unsubscribing.
*
* This interface is the equivalent of `IDisposable` in the .NET Rx implementation.
*/
trait Subscription {
val asJavaSubscription: rx.Subscription

/**
* Call this method to stop receiving notifications on the Observer that was registered when
* this Subscription was received.
*/
def unsubscribe(): Unit = asJavaSubscription.unsubscribe()

/**
* Checks if the subscription is unsubscribed.
*/
def isUnsubscribed: Boolean
}

object Subscription {

Expand Down