
io.vertx.rx.groovy.RxHelper Maven / Gradle / Ivy
package io.vertx.rx.groovy;
import io.vertx.groovy.core.Context;
import io.vertx.groovy.core.Vertx;
import io.vertx.groovy.core.buffer.Buffer;
import io.vertx.rx.java.UnmarshallerOperator;
import rx.Observable;
import rx.plugins.RxJavaSchedulersHook;
/**
* @author Julien Viet
*/
public class RxHelper {
/**
* Create a scheduler hook for a {@link io.vertx.groovy.core.Vertx} object
* @param vertx the vertx object
* @return the scheduler hook
*/
public static RxJavaSchedulersHook schedulerHook(Vertx vertx) {
return io.vertx.rx.java.RxHelper.schedulerHook((io.vertx.core.Vertx) vertx.getDelegate());
}
/**
* Create a scheduler hook for a {@link io.vertx.groovy.core.Vertx} object
* @param context the vertx object
* @return the scheduler hook
*/
public static RxJavaSchedulersHook schedulerHook(Context context) {
return io.vertx.rx.java.RxHelper.schedulerHook((io.vertx.core.Context) context.getDelegate());
}
/**
* Returns a json unmarshaller for the specified java type as a {@link rx.Observable.Operator} instance.
*
* The marshaller can be used with the {@link rx.Observable#lift(rx.Observable.Operator)} method to transform
* a {@literal Observable} into a {@literal Observable}.
*
* The unmarshaller buffers the content until onComplete is called, then unmarshalling happens.
*
* Note that the returned observable will emit at most a single object.
*
* @param mappedType the type to unmarshall
* @return the unmarshaller operator
*/
public static Observable.Operator unmarshaller(Class mappedType) {
return new UnmarshallerOperator(mappedType) {
@Override
public io.vertx.core.buffer.Buffer unwrap(Buffer buffer) {
return ((io.vertx.core.buffer.Buffer) buffer.getDelegate());
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy