java - Emit items in RxJava in an interval which depends on the emitted item itself -
java - Emit items in RxJava in an interval which depends on the emitted item itself -
in rxjava android, want emit items in interval depends on item itself: in observable, pull item queue, process , emit it. dependent on type of item, want adjust after time next item shall emitted (slow downwards or speed interval).
the next code, proposed @a.bertucci here emit objects drawing in ui in regular interval using rxjava on android demonstrates how emit items in regular interval.
private void drawpath(final string chars) { observable.zip( observable.create(new observable.onsubscribe<path>() { // drawing stuff here ... }), observable.timer(0, 50, timeunit.milliseconds), new func2<path, long, path>() { @override public path call(path path, long along) { homecoming path; } } ) .subscribeon(schedulers.newthread()) .observeon(androidschedulers.mainthread()) ... }
my question is, if possible @ modify emission frequency while observable emitting, , what's preferred implementation using rxjava.
you can use
public final <u, v> observable<t> delay( func0<? extends observable<u>> subscriptiondelay, func1<? super t, ? extends observable<v>> itemdelay)
or
public final <u> observable<t> delay(func1<? super t, ? extends observable<u>> itemdelay)
you can utilize itemdelay
command speed.
java android rx-java
Comments
Post a Comment