Apresentado no TDC Florianópolis - 2016.
Palestra voltada aos que ouviram falar sobre RxJava e querem aprender sobre a biblioteca que todos os programadores legais estão comentando.
6. 66
Reactive Programming | O Que é?
• Pull x Push: Ao invés de pedir algo e esperar, o desenvolvedor
simplesmente pede por algo e é notificado quando o resultado estiver
disponível.
• Paradigma baseado no conceito de fluxo de dados assíncrono.
• Mais flexível. O Desenvolvedor ignora se os dados chegam de forma
síncrona ou assíncrona. O código simplesmente funciona.
• Fontes de dados podem ser combinadas e não aninhadas, afastando o
desenvolvedor do “callback hell”
23. 2323
Exemplo | AsyncTask -> Reactive
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
Reactive Programming is a programming paradigm based on concept of an asynchronous data flow. Like a river: it can be observed, filtered, manipulated, or merged with a second flow to create a new flow for a new consumer.
nstead of asking for a result and waiting, the developer simply asks for result and gets notified when result is available.
Clearly more flexible, because from a logical and practical point of view, the developer can simply ignore if the data he needs comes sync or async, his code will still work.
Functional reactive programming idea from late 90s inspired Erik Meijer. Rx is a reactive extension for .NET which provides an easy way to create async, event-driven programs using Observables sequences. Model a data stream using Observables, query and manage concurrency using Schedulers.
Instead of asking for a result and waiting, the developer simply asks for result and gets notified when result is available.
Clearly more flexible, because from a logical and practical point of view, the developer can simply ignore if the data he needs comes sync or async, his code will still work.
5min
Behavioral pattern and ir provides a way to bind objects in a one-to-many dependency.: when one object changes, all the objects depending on it are notified and updated automatically.
RxJava Observables can be composed instead of nested, saving the developer from the callback hell.
Clear sequence of events that are going to happen. For every event the developer provides a reaction.
Three missing abilities:
The producer can now signal that there is no more data available: onCompleted() event.
The producer can now signal that an error occurred.