You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-38Lines changed: 24 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,55 +1,41 @@
1
-
# ReactiveElmish.Avalonia [](https://www.nuget.org/packages/ReactiveElmish.Avalonia/)
2
-
Static Avalonia views for Elmish programs
1
+
## ReactiveElmish.Avalonia [](https://www.nuget.org/packages/ReactiveElmish.Avalonia/)
3
2
4
-
## Why?
5
-
Avalonia.FuncUI and Fabulous.Avalonia already exist and they are both fantastic. So then why make an ReactiveElmish.Avalonia port?
* Some people may prefer using static xaml views, and it can be an easier sell for some teams due to the immediate availability of all community controls.
9
-
* Bindings have to be created for controls in FuncUI. While most of the controls have bindings provided, third party will not have bindings out-of-the-box. Elmish.Avalonia sidesteps this problem by using xaml directly.
24
+
* Some people may prefer using static xaml views, and it can be an easier sell for some teams due familiarity, and the immediate availability of all community controls.
10
25
* Ability to use the excellent Avalonia design previewer. For me to do any kind of real project work with Avalonia and F#, a design previewer is a necessity. Also, being able to easily construct `DesignInstance` VM for each view that utilizes the Elmish `init` function.
11
-
* You can still use Avalonia.FuncUI and ReactiveElmish.Avalonia side-by-side to have the best of both worlds approach if you like using the FuncUI DSL!
12
-
13
-
### Additional reasons
14
26
* Avalonia UI is a big deal in the .NET OSS community; it is always nice for F# community to be able to participate in the latest and greatest with as many options as possible.
15
27
* Avalonia already provides first class templates to create an F# project that include creating .axaml views within the same project! (Not possible with WPF!)
16
28
* While the built-in F# templates do allow you to do classic MVVM style, Elmish provides a powerful form of state management that has become standard for F# UI projects.
17
29
* The "Avalonia UI for Visual Studio 2022" extension provides a xaml preview pane that works with F#! 😄 (Also not possible with WPF!)
18
30
* Keeping with tradition that the F# community will [provide important libraries, developer tools and workload support](https://learn.microsoft.com/en-us/dotnet/fsharp/strategy).
19
31
20
-
# History
21
-
## Elmish.Avalonia
22
-
V1 of this project was a port of the awesome [Elmish.WPF](https://github.com/elmish/Elmish.WPF) library.
23
-
Most of the v1 codebase was directly copied, and the WPF bits were replaced with Avalonia bits and adapted where necessary.
24
-
The V1 bindings (see below) were translated into an internal `DictionaryViewModel` behind the scenes that was bound to the view's `DataContext`.
The ReactiveElmish has eolved into a complete rewrite, and all the code that was copied from Elmish.WPF is planned to be removed.
29
-
My vision for this library departs from the typical "monolithic" Elmish app. Instead, it uses more of a modular Elmish approach where each view model can run its own Elmish loop.
30
-
31
-
At the heart of V2 is the new `ReactiveElmishViewModel` base class, which inherits `ReactiveUI.ReactiveObject`.
32
-
Instead of using the V1 bindings, you now create a more standard view model that has able properties. A new `` method will take care of binding your view model properties to Elmish model projections.
* Works with Avalonia [Compiled bindings](https://docs.avaloniaui.net/docs/next/basics/data/data-binding/compiled-bindings#enable-and-disable-compiled-bindings) for better performance and compile-time type checking in the views. With Compiled bindings enabled, the build will fail if the view references a binding that doesn't exist in the VM! (The previous `DictionaryViewModel` brought over from Elmish.WPF was not able to take advantage of this because it relied on reflection-based bindings.)
39
34
* More standard looking view model pattern while still maintaining the power of Elmish. For example, you can now create an instance of an Elmish view model and actually inspect its properties from the outside -- and even read / write to the properties in OOP fashion. (The fact that a view model is using Elmish internally should not matter because it's an implementation detail.) This is a perfect example of the benefits of OOP + FP side-by-side.
40
35
* ReactiveElmish.Avalonia now takes a dependency on the Avalonia.ReactiveUI library. (The new `ReactiveElmishViewModel` class inherits from `ReactiveObject`.) Since this is the default view model library for Avalonia, this makes it easier to take advantage of existing patterns when needed.
41
36
* ReactiveElmish.Avalonia integrates with `DynamicData` which provides a very simple way to lists between the Elmish model and the view / view model.
42
-
* Built-in dependency injection using "Microsoft.Extensions.DependencyInjection".
43
-
44
-
## Design View
45
-
Don't forget to install the "Avalonia for Visual Studio 2022" extension.
46
-
JetBrains Rider also supports Avalonia previews out-of-the-box!
0 commit comments