RxJava и Android. Плюсы, минусы, подводные камниStfalcon Meetups
Ярослав Герьятович
Android Engineer в компании Attendify . Спикер на UA Mobile'14 . Идеолог функционального и реактивного подхода в проектировании Android приложений.
2019-10-05 - Untangled - Voxxed days ticinoArnaud Bos
Concurrent programming borrows a lot of terms from weaving and twists our minds with intertwined concepts: fibers, threads, lightweight-threads, green threads, loom...
Maybe you've heard about coroutines? Don't worry, everything is linked.
During this talk, we'll get weaving, show code samples and talk about project Loom, whose goal is to bring "lightweight concurrency" mechanisms to the JVM, along with APIs to embroider the story.
We will talk about project Loom's inception and recent prototypes. You will also see its mesh goes far beyond "simple" primitives to revolutionize the JVM.
Class 12 ip project on wwe management system
sql databases available
netbeans file available
made in year 2018-19
unique topic
easy java coding used
made in netbeans version 8.1
ready to print
RxJava и Android. Плюсы, минусы, подводные камниStfalcon Meetups
Ярослав Герьятович
Android Engineer в компании Attendify . Спикер на UA Mobile'14 . Идеолог функционального и реактивного подхода в проектировании Android приложений.
2019-10-05 - Untangled - Voxxed days ticinoArnaud Bos
Concurrent programming borrows a lot of terms from weaving and twists our minds with intertwined concepts: fibers, threads, lightweight-threads, green threads, loom...
Maybe you've heard about coroutines? Don't worry, everything is linked.
During this talk, we'll get weaving, show code samples and talk about project Loom, whose goal is to bring "lightweight concurrency" mechanisms to the JVM, along with APIs to embroider the story.
We will talk about project Loom's inception and recent prototypes. You will also see its mesh goes far beyond "simple" primitives to revolutionize the JVM.
Class 12 ip project on wwe management system
sql databases available
netbeans file available
made in year 2018-19
unique topic
easy java coding used
made in netbeans version 8.1
ready to print
program list:
WAP program to show constructor overloading using static member.
WAP to implement multilevel inheritance and method overriding.
WAP to implement interface class and show use of package.
WAP to implement multilevel exception handling and create your own exception.
WAP to implement 3 threads such that 1st sleeps for 200ms, 2nd for 400ms and 3rd for 600ms.
WAP to create applet of moving banner.
WAP to make a simple calculator.
Build a client server chat application.
Use C++ to Manipulate mozSettings in GeckoChih-Hsuan Kuo
If you want to manipulate mozSettings with JavaScript, you can reference to Settings API on MDN (https://developer.mozilla.org/en-US/docs/Web/API/Settings_API).
But if you want to manipulate it with C++, we can only reference to the codebase of Gecko. Now, let me show you some example.
Тема №2 Расширяем сознание реактивным подходом. RxJava и Android
Спикер — Владимир Артеменко — android developer Компания Rooky Pro
Уровень аудитории — Теория есть, начальный опыт применения
Цель доклада – Обучение
program list:
WAP program to show constructor overloading using static member.
WAP to implement multilevel inheritance and method overriding.
WAP to implement interface class and show use of package.
WAP to implement multilevel exception handling and create your own exception.
WAP to implement 3 threads such that 1st sleeps for 200ms, 2nd for 400ms and 3rd for 600ms.
WAP to create applet of moving banner.
WAP to make a simple calculator.
Build a client server chat application.
Use C++ to Manipulate mozSettings in GeckoChih-Hsuan Kuo
If you want to manipulate mozSettings with JavaScript, you can reference to Settings API on MDN (https://developer.mozilla.org/en-US/docs/Web/API/Settings_API).
But if you want to manipulate it with C++, we can only reference to the codebase of Gecko. Now, let me show you some example.
Тема №2 Расширяем сознание реактивным подходом. RxJava и Android
Спикер — Владимир Артеменко — android developer Компания Rooky Pro
Уровень аудитории — Теория есть, начальный опыт применения
Цель доклада – Обучение
An exploration into RxJava on Android for the experienced, yet uninitiated software engineer. This presentation explores Declarative vs Imperative programming paradigms and expands the discussion into Functional Reactive Programming. It explains the benefits of the observer contract, high-order functions, and schedulers available in RxJava. It also explains the purpose of the Android integration libraries: RxAndroid, RxLifecycle, and RxBindings.
In a world where users have ever higher expectations from the apps they use, having data always available, even when the device is offline, has become increasingly important.
In this talk you will learn how thinking "offline first" not only makes your app architecture better but also result in cleaner code and happier users.
I will introduce Realm, a new database for easy persistence, and demonstrate how it enables truly reactive UI's by fitting seamlessly into the standard network stack of Retrofit and RxJava.
Finally we will take a look at the new Realm Mobile Platform, which provides real-time synchronization between devices, enabling features previously out of reach for many development teams.
Poche chiacchiere e tanto codice per cercare rendere la nostra vita di
sviluppatori più divertente.
Parleremo di JAX-RS, le annotazioni, l'MVC che mette a disposizione e
l'integrazione di Jersey con Guice.
Useremo AOP per gestire log, transazioni e con l'aiuto di Infinispan
limiteremo le chamate concorrenti sul nostro cluster.
Workshop slides from the Alt.Net Seattle 2011 workshop. Presented by Wes Dyer and Ryan Riley. Get the slides and the workshop code at http://rxworkshop.codeplex.com/
Ten useful JavaScript tips & best practicesAnkit Rastogi
In this presentation there are ten useful JavaScript techniques which can be included in your application easily with less friction along with some AngularJs tips and best practices as a bonus. These tips and best practices are accompanied by examples & will cover script loading, design pattern, performance optimization and other areas.
Since best practices are very subjective topics, proper benchmarking needs to be done.
REX about JavaFX8 used in SlideshowFX. This presentation covers concept from JavaFX as well as technologies like OSGi, Vert.x, LeapMotion, nashorn and friends in order to make them communicate inside one application developed in JavaFX.
This presentation was made at the ElsassJUG
Similar to 드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅 (20)
2. Rx Contract #1-1
no more messages should arrive after an onError or
onComplete message
RxView.clicks(button)
.flatMap(ignored -> getBestSeller()
.subscribeOn(Schedulers.io()))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(bookTitle -> title.setText(bookTitle),
e -> Toast.makeText(this, "문제 발생",
Toast.LENGTH_LONG).show()
);
무한 이벤트에서 문제 발생 가능
4. Rx Contract #1-3
interface ViewState {
class Error implements ViewState {
Throwable e;
Error(Throwable e) {
this.e = e;
}
}
class Result implements ViewState {
String title;
Result(String title) {
this.title = title;
}
}
}
http://hannesdorfmann.com/android/
mosby3-mvi-1
visual bugs such as displaying a loading
indicator (“loading state”) and error indicator
(“error state”) at the same time => exactly
one output
5. Rx Contract #2-1
스트림에 널(null) 허용 안됨
@Test(expected = NullPointerException.class)
public void nullEvent() {
Observable.just("Hello", null, "RxJava")
.subscribe(System.out::println,
System.err::println);
}
Observable 생성
에서 에러 발생
6. Rx Contract #2-2
@Test
public void nullEventOnCreate() {
Observable.create(emitter -> {
emitter.onNext("Hello");
emitter.onNext(null);
emitter.onNext("RxJava");
}).subscribe(System.out::println,
System.err::println);
}
java.lang.NullPointerException:
onNext called with null. Null
values are generally not
allowed in 2.x operators and
sources.
7. Rx Contract #2-3
@Test
public void nullEventPossible() {
Observable.just(1, 2, -1, 1, 2)
.map(dollar -> getCurrentPrice(dollar))
.subscribe(System.out::println,
System.err::println);
}
private String getCurrentPrice(int dollar) {
if (dollar < 0) {
return null;
}
return (dollar * 1000) + " won";
}
1000 won
2000 won
java.lang.NullPointerException:
The mapper function returned
a null value.
8. Rx Contract #2-4
@Test
public void nullEventPossible3() {
Observable.just(1, 2, -1, 1, 2)
.map(dollar -> getCurrentPrice3(dollar))
.onErrorReturnItem("0 won")
.subscribe(System.out::println,
System.err::println,
() -> System.out.println("onComplete"));
}
private String getCurrentPrice3(int dollar) {
if (dollar < 0) {
throw new IllegalArgumentException("dollar should be bigger than 0");
}
return (dollar * 1000) + " won";
} [1000 won, 2000 won, 0 won, onComplete]
9. Rx Contract #2-5
@Test
public void nullEventPossible4() {
Observable.just(1, 2, -1, 1, 2)
.flatMap(dollar -> getCurrentPrice4(dollar)
.onErrorReturnItem("0 won")) // (1)
.subscribe(System.out::println,
System.err::println);
}
private Observable getCurrentPrice4(int dollar) {
if (dollar < 0) {
return Observable.error(
new IllegalArgumentException("dollar should be bigger than 0")); // (2)
}
return Observable.just((dollar * 1000) + " won"); // (3)
}
10. Rx Contract #3-1
Assume observer instances are called in a serialized fashion
Observable obs = Observable.create(emitter -> {
new Thread(() -> {
emitter.onNext(1);
emitter.onNext(3);
. . . .
emitter.onNext(9);
// emitter.onComplete(); // (1)
}).start();
new Thread(() -> {
emitter.onNext(2);
emitter.onNext(4);
. . . .
emitter.onNext(10);
// emitter.onComplete(); // (2)
}).start();
});
onComplete 넣
을 수 없음
24. RetryWhen #2
public Single<Profile> getProfile() {
return profileRepository.getProfile().retryWhen(errors ->
errors.zipWith(Flowable.range(0, LIMIT),
this::handleRetryAttempt).flatMap(x -> x));
}
private Flowable<Long> handleRetryAttempt(Throwable throwable, int attempt) {
if (throwable instanceof SocketTimeoutException) {
switch (attempt) {
case LIMIT:
return Flowable.error(throwable);
default:
return Flowable.timer(attempt * 3, TimeUnit.SECONDS);
}
} else {else if (throwable instanceof HttpException) {
// 다음 슬라이드
}
OkHttpClient Interceptor도 가능?
원래 흐름으로 돌아올 방법 없음
25. RetryWhen #3
private Flowable<Long> handleRetryAttempt(Throwable throwable, int attempt) {
if (throwable instanceof SocketTimeoutException) {
...
} else if (throwable instanceof HttpException) {
int statusCode = ((HttpException) throwable).code();
if (statusCode == 401) {
return profileRepository.refresh().retry((refreshAttempt, e) ->
refreshAttempt < LIMIT
&& e instanceof SocketTimeoutException)
.map(x -> 1L).toFlowable();
}
}
return Flowable.error(throwable);
}
26. RetryWhen #4
public class RetryTransformer<T> implements SingleTransformer<T, T> {
. . . .
@Override
public SingleSource apply(Single<T> upstream) {
return upstream.retryWhen(errors ->
errors.zipWith(Flowable.range(0, LIMIT),
this::handleRetryAttempt).flatMap(x -> x));
}
}
public Single<Profile> getProfile() {
return profileRepository.getProfile().compose(retryTransformer);
}
27. 예외 처리 #1
public long getTimeInMillis1(String input) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
return sdf.parse(input).getTime();
}
public long getTimeInMillis2(String input) {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
try {
return sdf.parse(input).getTime();
} catch (ParseException e) {
e.printStackTrace();
return -1L; // -1을 상수로 해도 큰 차이가 없음
}
}
28. 예외 처리 #2
public long getTimeInMillis3(String input) {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
try {
return sdf.parse(input).getTime();
} catch (ParseException e) {
throw new IllegalArgumentException("Illegal input pattern");
}
}
29. 예외 처리 #3
public Single<Long> getTimeInMillis(String input) {
return Single.fromCallable(() -> {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
return sdf.parse(input).getTime();
});
}
String input = "2017-xx-30 02:20:20";
DateFormatter formatter = new DateFormatter();
long start = formatter.getTimeInMillis(input)
.onErrorReturnItem(0L)
.blockingGet();
long end = formatter.getTimeInMillis(input)
.onErrorReturnItem(new Date().getTime())
.blockingGet();
System.out.println("start=" + start + ", end=" + end);