/Clean-Way-Rx-JavaScript

I recommend this reading for any actor that participates in the design, implementation, and validation processes of software components through Reactive programming and Functional programming, supported by the use of Rx extensions.

Primary LanguageTypeScript

Book: The Clean Way to Use Rx

This work, groups the different practices used in the implementation of software components through Rx extensions. These practices are organized into 35 application items, and for each item, it is analyzed, which are the recommended code practices and the practices to avoid.

It could also be said that this document is the compilation of good practices learned through the own experience acquired in business projects, recommendations received from forums, blogs, workshops and in general from analyzes given by experts in the area, including the recommendations given in the official sites of each extension.

This book is also intended as a practical reference manual for implementing Rx code. That is why much of the book's material consists of examples of code snippets written in the main programming languages ​​for both Frontend (Mobile, Web; that is, JavaScript, Swift, Java) such as Backend.

The concepts studied in each of the items are agnostic to the programming language, there are few cases in which a certain capacity is not available in an extension and in which case the respective annotation is made in the item.

It is intended that once the concepts of each item have been studied, the reader benefits from a greater understanding of how Rx works.

Readers will also be equipped with tools to apply good practices that are ultimately reflected in the solutions in the area of:

  • Clean Code.
  • Best performance:
  • Mitigate bugs scenarios.

Book: The Clean Way to Use Rx

Rules summary

Foundation

Ítem 1: From Imperative to Reactive

Ítem 2: Focus on pure functions

Ítem 3: Check the nature of the streams when they are linked

Ítem 4: Decide when to use an Observable type empty or never

Be Clean

Ítem 5: Keep clean the operators' chain

Ítem 6: Define functional operator chains

Ítem 7: Do not nest subscriptions, use operator chain

Ítem 8: Use Rx when there are events involved

Ítem 9: Do not orchestrate Rx operations with imperative programming

Ítem 10: Do not include Rx code in Do operators

Ítem 11: Propagate wrappers, not units

Ítem 12: Avoid propagating null values, turn to Optionals

Ítem 13: Remember you can use a filter, instead of if sentence

Ítem 14: It is possible to divide the emission when if-else is presented

Ítem 15: Sharing code is not the same as sharing emissions

Ítem 16: Not everything is delegated to the Observer

Ítem 17: Delay as much as possible the definition of the Schedule

Flow dependencies

Ítem 18: Check completion or error events when using filters

Ítem 19: Beware of reduction operators on infinite streams

Ítem 20: Maintain consistency like the stream

Ítem 21: Be careful when you depend on onComplete

Ítem 22: An additional step in the operator chain

Ítem 23: Orchestrating and combining effectively

Operators

Ítem 24: Properly select operators

Ítem 25: Use the map operator only for transformations

Timing

Ítem 26: Make sure you execute the tasks at the right time

Ítem 27: Control execution times on dependent tasks

Error handling

Ítem 28: Handling errors

Multicasting

Ítem 29: Share Observables, share Observers or both

Multi-threading

Ítem 30: Rx is single-threaded by default

Ítem 31: Do the order of the subscribeOn and observeOn operators matter?

Ítem 32: Some operators bring a predefined Scheduler

Ítem 33: Negotiating with UI

Optimizing

Ítem 34: Properly canceling the subscription

Ítem 35: When to use Subjects or Traits?

Versions of IDEs and technologies used.

  • Xcode 11.5 - Swift 5
  • Android Studio 4.0 - Java 1.8.0
  • Visual Studio Code 1.47.1 - TypeScript 3.8.3 - Angular 9.1.0

Other technologies

The reader will also be able to access the public repositories written for each technology at: