From 6f769d6fec332bd7e325a90a7645c422239b5c63 Mon Sep 17 00:00:00 2001 From: Daniil Korostelev Date: Fri, 21 Jun 2024 15:20:54 +0200 Subject: [PATCH] add doc section on R3 and TinkState (closes #28) --- docs/articles/rx.md | 35 +++++++++++++++++++++++++++++++++++ docs/articles/toc.yml | 4 +++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 docs/articles/rx.md diff --git a/docs/articles/rx.md b/docs/articles/rx.md new file mode 100644 index 0000000..7964400 --- /dev/null +++ b/docs/articles/rx.md @@ -0,0 +1,35 @@ +# Rx/R3 and TinkState# + +Probably the most popuplar general reactivity framework is [Rx](https://reactivex.io/). For C# (and Unity) a great implementation of it is [R3](https://github.com/Cysharp/R3/) (former UniRx). + +The use cases and some functionality of R3 and TinkState# interesects, which might rise a question of which library to choose for your project. Let's try comparing TinkState# and R3 regarding their scope, philosophy and technical implementation. + +--- + +**R3** defines observables and observers in a very generic way, more or less in the spirit of standard .NET IObservable/IObserver: + - Observable is anything that can be subscribed to. + - Observer is a set of callbacks (next/error/complete) invoked by the subscribed observable. + +So basically, an R3 observable is a potentially finite stream of values with error handling. The power comes from a large library of LINQ-like observable implementations (operators and factories) that you can chain together to filter, combine and transform these streams and ultimately subscribe to the final values. + +One important (in our context) kind of R3 observable is ReactiveProperty, which is a wrapper around a value +that notifies its observers when you change it. + +--- + +**TinkState#** however focuses specifically on observable *values* rather than generic notifications, thus its definition of Observable is different: + + - Observable represents a value that can change. + - Bindings can be added to observables to react to their values. + +From these definitions, TinkState# Observable is closer to R3 ReactiveProperty and instead of thinking in terms of value streams and processing pipelines, we operate with observable values and bindings to them. + +When it comes to processing values and creating derived observables, instead of the aforementioned collection of operator/factory observables found in R3, TinkState# relies on the idea of [*auto-observables*](auto.md), which are created from a computation function that automatically tracks source observables without the need to explicitly link them together. + +--- + +As you can see, TinkState# focus is much narrower, it doesn't seek to unify *anything that can be reacted to* under the standard API and instead aims to streamline mutable state management and provide minimalistic and concise APIs for that. Whether that's a good thing or not - that's up to the reader to decide for their projects. :) + +--- + +> TODO: add performance benchmark comparisons for the intersecting functionality diff --git a/docs/articles/toc.yml b/docs/articles/toc.yml index 0fa80c5..75f4328 100644 --- a/docs/articles/toc.yml +++ b/docs/articles/toc.yml @@ -51,5 +51,7 @@ href: unity-lifetime-helper.md - name: Godot Specifics - href: Godot.md + href: godot.md +- name: Rx/R3 and TinkState# + href: rx.md