The document provides an overview of a talk on Functional Reactive Programming (FRP) and Kotlin. The key points covered include:
- An introduction to FRP as a programming paradigm focused on reacting to streams of data changes.
- Examples of FRP concepts like streams, functions composition, and reactive extensions operators like flatMap, scan, groupBy, and debounce.
- An overview of Kotlin features like data classes, nullable types, default arguments, lambdas, and extension functions.
- How RxKotlin allows combining FRP and Android using Observables to handle user input and events in a reactive way.
AI Fame Rush Review â Virtual Influencer Creation In Just Minutes
Â
Functional Reactive Programming with Kotlin on Android - Giorgio Natili - Codemotion Milan 2016
1. + ^
| | @giorgionatili
+-------------------------------------+--------------+
FRP + Kotlin
A journey into new programming paradigms
and magical operators
2. +--------------X----X---X---X---X------------>
+---------------------------------#MobileTea->
About Me
/ :
/ :'
.. / :'
( , '
|( '
( ` .---.
`
.-..-.
( _.._.--. `.
' '._`-._..-'``__ `-. '. ..7
'. ``` /``` `'. `-.-~-.`-/
.-.:>. __. '. | ( `'
( ( . . )
`'-._ `'(__. :
.7 (_. ( :
.' , '-
__--': . . `'
/ ,: ,/ /__. . .
'--'` `--' `' / | : /|
/ | |` |
/ | : (
.' .'| '. '
( / | : '.
( (
)./-
(` ,./.-''-:.
+ Engineering Manager at Akamaiâš
(NG2 on desktop and mobile)
+ VP of Engineering at Sync Thinkâš
(Android, VR and Python)
+ Founder of Mobile Tea âš
(www.meetup.com/pro/mobiletea)
+ Leader of the Boston Twitter UG
+ Organizer of DroidCon Bostonâš
(www.droidcon-boston.com)
28. +--------------X----X---X---X---X------------>
+---------------------------------#MobileTea->
Handling User Input
Observable.create(new Observable.OnSubscribe<String>() {
@Override
public void call(final Subscriber<? super String> subscriber) {
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(final CharSequence s,
final int start, final int count, final int after){}
@Override
public void onTextChanged(final CharSequence s,
final int start, final int before, final int count) {âš
subscriber.onNext(s.toString());
}
@Override
public void afterTextChanged(final Editable s) { }
});
}
})
.debounce(1000, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<String>() {
@Override
public void call(final String s) {
textView.setText("Output : " + s);
}
});
Create
Emit
Handle stream
Subscribe
30. + ^
| | @giorgionatili
+-------------------------------------+--------------+
Kotlin in a
Nutshell
60. +--------------X----X---X---X---X------------>
+---------------------------------#MobileTea->
Schedulers
+ immediate(), creates and returns a Scheduler that
executes work immediately on the current thread
+ trampoline(), creates and returns a Scheduler
that queues work on the current thread to be
executed after the current work completes
+ newThread(), creates and returns a Scheduler that
creates a new Thread for each unit of work
+ computation(), creates and returns a Scheduler
intended for computational work
+ io(), creates and returns a Scheduler intended
for IO-bound work (unbounded, multiple threads)
71. Scheduleâš
7:00 pm - 7:30 pm Welcome with beers and snacks
7:30 pm - 8:35 pm Screening of "Design Disruptors"
8:35 pm - 9:30 pm Networking moment and aperitif
GiovedĂŹ 1 Dicembre, ore 19:00 , Luiss Enlabs, Stazione Termini, Roma
DESIGN DISRUPTORS is a full-length documentary
featuring design leaders and product designers from
15+ industry-toppling companiesâvalued at more
than $1trillion dollars combined.
Free, but registration is required :)