Java Code Examples for io.reactivex.rxjava3.core.Flowable#map()
The following examples show how to use
io.reactivex.rxjava3.core.Flowable#map() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CacheAndRemoteStrategy.java From RxCache with Apache License 2.0 | 6 votes |
@Override public <T> Publisher<Record<T>> execute(RxCache rxCache, String key, Flowable<T> source, Type type) { Flowable<Record<T>> cache = rxCache.<T>load2Flowable(key, type); Flowable<Record<T>> remote = source .map(new Function<T, Record<T>>() { @Override public Record<T> apply(@NonNull T t) throws Exception { rxCache.save(key, t); return new Record<>(Source.CLOUD, key, t); } }); return Flowable.concatDelayError(Arrays.asList(cache, remote)) .filter(new Predicate<Record<T>>() { @Override public boolean test(@NonNull Record<T> record) throws Exception { return record.getData() != null; } }); }
Example 2
Source File: CacheAndRemoteStrategy.java From RxCache with Apache License 2.0 | 6 votes |
@Override public <T> Publisher<Record<T>> execute(RxCache rxCache, String key, Flowable<T> source, Type type, BackpressureStrategy backpressureStrategy) { Flowable<Record<T>> cache = rxCache.<T>load2Flowable(key, type, backpressureStrategy); Flowable<Record<T>> remote = source .map(new Function<T, Record<T>>() { @Override public Record<T> apply(@NonNull T t) throws Exception { rxCache.save(key, t); return new Record<>(Source.CLOUD, key, t); } }); return Flowable.concatDelayError(Arrays.asList(cache, remote)) .filter(new Predicate<Record<T>>() { @Override public boolean test(@NonNull Record<T> record) throws Exception { return record.getData() != null; } }); }
Example 3
Source File: RemoteFirstStrategy.java From RxCache with Apache License 2.0 | 6 votes |
@Override public <T> Publisher<Record<T>> execute(RxCache rxCache, String key, Flowable<T> source, Type type) { Flowable<Record<T>> cache = rxCache.<T>load2Flowable(key, type); Flowable<Record<T>> remote = source .map(new Function<T, Record<T>>() { @Override public Record<T> apply(@NonNull T t) throws Exception { rxCache.save(key, t); return new Record<>(Source.CLOUD, key, t); } }); return remote.switchIfEmpty(cache); }
Example 4
Source File: RemoteFirstStrategy.java From RxCache with Apache License 2.0 | 6 votes |
@Override public <T> Publisher<Record<T>> execute(RxCache rxCache, String key, Flowable<T> source, Type type, BackpressureStrategy backpressureStrategy) { Flowable<Record<T>> cache = rxCache.<T>load2Flowable(key, type, backpressureStrategy); Flowable<Record<T>> remote = source .map(new Function<T, Record<T>>() { @Override public Record<T> apply(@NonNull T t) throws Exception { rxCache.save(key, t); return new Record<>(Source.CLOUD, key, t); } }); return remote.switchIfEmpty(cache); }
Example 5
Source File: CacheFirstStrategy.java From RxCache with Apache License 2.0 | 6 votes |
@Override public <T> Publisher<Record<T>> execute(RxCache rxCache, String key, Flowable<T> source, Type type) { Flowable<Record<T>> cache = rxCache.<T>load2Flowable(key, type); Flowable<Record<T>> remote = source .map(new Function<T, Record<T>>() { @Override public Record<T> apply(@NonNull T t) throws Exception { rxCache.save(key, t); return new Record<>(Source.CLOUD, key, t); } }); return cache.switchIfEmpty(remote); }
Example 6
Source File: CacheFirstStrategy.java From RxCache with Apache License 2.0 | 6 votes |
@Override public <T> Publisher<Record<T>> execute(RxCache rxCache, String key, Flowable<T> source, Type type, BackpressureStrategy backpressureStrategy) { Flowable<Record<T>> cache = rxCache.<T>load2Flowable(key, type, backpressureStrategy); Flowable<Record<T>> remote = source .map(new Function<T, Record<T>>() { @Override public Record<T> apply(@NonNull T t) throws Exception { rxCache.save(key, t); return new Record<>(Source.CLOUD, key, t); } }); return cache.switchIfEmpty(remote); }
Example 7
Source File: RemoteOnlyStrategy.java From RxCache with Apache License 2.0 | 6 votes |
@Override public <T> Publisher<Record<T>> execute(RxCache rxCache, String key, Flowable<T> source, Type type) { Flowable<Record<T>> remote = source .map(new Function<T, Record<T>>() { @Override public Record<T> apply(@NonNull T t) throws Exception { rxCache.save(key, t); return new Record<>(Source.CLOUD, key, t); } }); return remote; }
Example 8
Source File: RemoteOnlyStrategy.java From RxCache with Apache License 2.0 | 6 votes |
@Override public <T> Publisher<Record<T>> execute(RxCache rxCache, String key, Flowable<T> source, Type type, BackpressureStrategy backpressureStrategy) { Flowable<Record<T>> remote = source .map(new Function<T, Record<T>>() { @Override public Record<T> apply(@NonNull T t) throws Exception { rxCache.save(key, t); return new Record<>(Source.CLOUD, key, t); } }); return remote; }
Example 9
Source File: CacheFirstTimeoutStrategy.java From RxCache with Apache License 2.0 | 6 votes |
@Override public <T> Publisher<Record<T>> execute(RxCache rxCache, String key, Flowable<T> source, Type type) { Flowable<Record<T>> cache = rxCache.<T>load2Flowable(key, type) .filter(new Predicate<Record<T>>() { @Override public boolean test(Record<T> record) throws Exception { return System.currentTimeMillis() - record.getCreateTime() <= timestamp; } }); Flowable<Record<T>> remote = source .map(new Function<T, Record<T>>() { @Override public Record<T> apply(@NonNull T t) throws Exception { rxCache.save(key, t); return new Record<>(Source.CLOUD, key, t); } }); return cache.switchIfEmpty(remote); }
Example 10
Source File: CacheFirstTimeoutStrategy.java From RxCache with Apache License 2.0 | 6 votes |
@Override public <T> Publisher<Record<T>> execute(RxCache rxCache, String key, Flowable<T> source, Type type, BackpressureStrategy backpressureStrategy) { Flowable<Record<T>> cache = rxCache.<T>load2Flowable(key, type, backpressureStrategy) .filter(new Predicate<Record<T>>() { @Override public boolean test(Record<T> record) throws Exception { return System.currentTimeMillis() - record.getCreateTime() <= timestamp; } }); Flowable<Record<T>> remote = source .map(new Function<T, Record<T>>() { @Override public Record<T> apply(@NonNull T t) throws Exception { rxCache.save(key, t); return new Record<>(Source.CLOUD, key, t); } }); return cache.switchIfEmpty(remote); }
Example 11
Source File: NoCacheStrategy.java From RxCache with Apache License 2.0 | 5 votes |
@Override public <T> Publisher<Record<T>> execute(RxCache rxCache, String key, Flowable<T> source, Type type) { return source.map(new Function<T, Record<T>>() { @Override public Record<T> apply(@NonNull T t) throws Exception { return new Record<>(Source.CLOUD, key, t); } }); }
Example 12
Source File: NoCacheStrategy.java From RxCache with Apache License 2.0 | 5 votes |
@Override public <T> Publisher<Record<T>> execute(RxCache rxCache, String key, Flowable<T> source, Type type, BackpressureStrategy backpressureStrategy) { return source.map(new Function<T, Record<T>>() { @Override public Record<T> apply(@NonNull T t) throws Exception { return new Record<>(Source.CLOUD, key, t); } }); }