Expand description
ferroui-reactiveui
A port of ReactiveUI (https://github.com/reactiveui/ReactiveUI) to Rust, in the flavour that
runs on System.Reactive (here ferroui-reactive), together with the run time of
ReactiveUI.Binding: reactive objects, commands, the observation of properties and the bindings
of view models and views for MVVM. It depends on nothing of the user interface of FerroUI; the
integration with the framework (the scheduler of the dispatcher, the observation of the
properties of controls, the views) builds on it.
The modules follow the folders of ReactiveUI.Core and ReactiveUI.Shared, in snake case, and the
run time of ReactiveUI.Binding is under binding. Everything public is re-exported at the
root, as upstream puts it in the namespaces ReactiveUI and ReactiveUI.Binding:
- [
reactive_object]:ReactiveObject, the part of a view model that notifies the changes of its properties (IReactiveObject,IReactiveObjectExt),ReactiveRecord, and the macrosreactive_object!andreactive_properties!that write a view model’s traits and properties. interfaces: the change notifications (IReactiveNotifyPropertyChanged,ReactivePropertyChangedEventArgs) andIHandleObservableErrors.- The root:
RxSchedulers,RxState,RxCacheSizeandUnhandledErrorException.
A view model holds a ReactiveObject and is shared as an Rc:
use ferroui_reactiveui::{reactive_object, reactive_properties, IReactiveNotifyPropertyChanged, ReactiveObject};
use ferroui_reactive::ObservableExt;
use std::cell::Cell;
use std::rc::Rc;
reactive_properties! {
#[derive(Default)]
pub struct Counter {
reactive: ReactiveObject,
#[reactive]
count: i32,
}
}
reactive_object!(Counter);
let counter = Rc::new(Counter::default());
let changes = Rc::new(Cell::new(0));
let seen = changes.clone();
let _subscription = counter.changed().subscribe_next(move |_| seen.set(seen.get() + 1));
counter.set_count(1);
counter.set_count(1);
assert_eq!(changes.get(), 1);Everything is single-threaded and reference counted, as the object model of FerroUI is
(docs/porting/reactive.md, section 5.1). An exception of user code is a panic; where upstream
catches one, the port catches the panic (PanicException).
Re-exports§
pub use binding::bindings::*;pub use binding::builder::*;pub use binding::command_binding::*;pub use binding::interactions::*;pub use binding::interfaces::*;pub use binding::mixins::*;pub use binding::observable_for_property::*;pub use binding::observables::*;pub use interfaces::*;pub use mixins::*;pub use reactive_command::*;pub use reactive_object::*;pub use scheduler::*;pub use binding::view::*;pub use activation::*;pub use routing::*;pub use suspension::*;pub use builder::*;pub use change_sets::*;pub use comparers::*;pub use reactive_property::*;pub use registration::*;
Modules§
- activation
ReactiveUI.Shared/ActivationandShared/ActivationSignals.cs: the activation of views and view models.- binding
- ReactiveUI.Binding (the run time): property observation, output properties and, in later waves, the bindings of views (docs/porting/reactive.md, section 3.2).
- builder
- The builder of a ReactiveUI application (
ReactiveUI.Shared/Builder, withInterfaces/IViewModule.csandMixins/BuilderMixins*.cs): Splat’s application builder with the services, schedulers, converters and state of ReactiveUI, the replacement of the formerRxAppinitialization. - change_
sets - The change sets of ReactiveUI (
ReactiveUI.Core/ChangeSets,ReactiveUI.Core/Mixins/ChangeSetMixins.csandShared/Platform/ChangeSetBinder.cs): the changes of a notifying collection as a stream of batches of per-item changes, the light layer that replaced DynamicData inside ReactiveUI. - comparers
- The comparers (
ReactiveUI.Core/Comparers): orders built by chaining keys (OrderedComparer<T>::order_by(..).then_by(..)). - interfaces
- The interfaces of ReactiveUI.Core and ReactiveUI.Shared (
Interfaces/) that are not those of commands, routing, suspension or activation: the change notifications of reactive objects and the errors of their pipelines. - mixins
Mixins(ReactiveUI.Shared/Mixins): the extension methods of observables (ObservableMixins,SwitchSubscribeMixins, the logging mixins) and AutoPersist.- platform
- The helpers that the platforms of ReactiveUI share (
Shared/Platform,Shared/ViewContractObservableHelpers.cs,Shared/ViewHostResolution.cs): small observables and sinks without operator pipelines, the view contract of the view hosts, and their view lookup. - reactive_
command ReactiveCommand(ReactiveUI.Core/ReactiveCommandandReactiveUI.Shared/ReactiveCommand): commands whose executions are observables, with the streams of their state (CanExecute,IsExecuting,ThrownExceptions), andICommand, the command a view executes.- reactive_
object ReactiveObject(ReactiveUI.Core/ReactiveObject,ReactiveUI.Shared/ReactiveObject): the base of view models, which notifies the changes of its properties as events and observables, with the suppression and delay of the notifications, and the macros that write a view model’s reactive object and properties.- reactive_
property ReactiveProperty(ReactiveUI.Core/ReactiveProperty,ReactiveUI.Shared/ReactiveProperty): a property that is its own observable, with validation throughINotifyDataErrorInfo, and the shared arguments of its notifications.- registration
- The registration of ReactiveUI’s services (
ReactiveUI.Core/Registration,ReactiveUI.Shared/Registration), with the interfaces it uses (IRegistrar,IWantsToRegisterStuff,IPlatformOperations) and the registration of views (MutableDependencyResolverExtensions,MutableDependencyResolverAOTExtensions). - routing
ReactiveUI.Shared/RoutingandReactiveUI.Core/Routing: the navigation stack of a screen and the message bus.- scheduler
ReactiveUI.Shared/Scheduler: the subject that delivers on a scheduler.- suspension
ReactiveUI.Shared/Suspension: the suspension and resumption of an application.
Macros§
- reactive_
object - Makes a type that holds a
ReactiveObjecta reactive object: writes itsINotifyPropertyChanged(withas_notify_property_changing),INotifyPropertyChanging,IEnableLogger,IReactiveObjectandIHandleObservableErrors. - reactive_
properties - Declares a view model’s struct with its notifying properties
(ReactiveUI.SourceGenerators’
[Reactive]). - settable_
prop - A
SettablePropertyfrom getters: the path ofprop!and the setterset_<last getter>of the object that owns the last property. - view_
for - Implements
IActivatableView,IViewForandIViewForOf<VM>for a view.
Structs§
- Panic
Exception - The error of a panic of user code, caught where upstream catches an exception: the message of the panic.
- RxCache
Size - The sizes of the caches of ReactiveUI (
RxCacheSize): the memoizing caches of view location and of the observation of properties. - RxSchedulers
- The schedulers that ReactiveUI’s objects run their work on (
RxSchedulers), settable for tests and by the integration with the user interface. - RxState
- The state of ReactiveUI that its objects share (
RxState): the handler of the errors that nothrown_exceptionssubscriber handles. - RxSuspension
- The suspension host of the application, for the events of the life of its process, such as
its suspension and resumption on a mobile device (
RxSuspension). - Unhandled
Error Exception - The error of a pipeline that broke because nothing handled its error
(
UnhandledErrorException): whatRxState::default_exception_handlerpanics with when an object implementingIHandleObservableErrorserrors and nothing subscribes to itsthrown_exceptions.
Traits§
- IThread
Affine Sequencer - A scheduler bound to one thread, which can tell whether the calling thread is that thread
(
IThreadAffineSequencer), as a dispatcher can. In theReactiveflavour a sequencer is anIScheduler.