Skip to content

Commit b235c3e

Browse files
authored
Update readme from beta
1 parent 760baac commit b235c3e

File tree

1 file changed

+24
-38
lines changed

1 file changed

+24
-38
lines changed

README.md

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,41 @@
1-
# ReactiveElmish.Avalonia [![NuGet version (ReactiveElmish.Avalonia)](https://img.shields.io/nuget/v/ReactiveElmish.Avalonia.svg?style=flat-square)](https://www.nuget.org/packages/ReactiveElmish.Avalonia/)
2-
Static Avalonia views for Elmish programs
1+
## ReactiveElmish.Avalonia [![NuGet version (ReactiveElmish.Avalonia)](https://img.shields.io/nuget/v/ReactiveElmish.Avalonia.svg?style=flat-square)](https://www.nuget.org/packages/ReactiveElmish.Avalonia/)
32

4-
## Why?
5-
Avalonia.FuncUI and Fabulous.Avalonia already exist and they are both fantastic. So then why make an ReactiveElmish.Avalonia port?
3+
_Elmish Stores + Custom Bindings + Avalonia Static Views_
4+
5+
### Elmish Stores + Custom bindings
6+
* Create an [Elmish Store](#elmish-stores) to share global app state between views.
7+
* Create an [Elmish Store](#elmish-stores) to manage local view state.
8+
* Use the [Custom Bindings](#view-model-bindings) in the `ReactiveElmishViewModel` base class to bind data from your Elmish Stores to your Views.
9+
10+
_This example shows using an Elmish Store to manage local view state:_
11+
![image](https://github.com/JordanMarr/ReactiveElmish.Avalonia/assets/1030435/5278afe4-ce05-4548-b9e9-6a1703394fd7)
12+
13+
### Avalonia Static Views
14+
Create views using Avalonia xaml.
15+
16+
Install the _Avalonia for Visual Studio 2022_ extension for a design preview panel.
17+
JetBrains Rider also supports Avalonia previews out-of-the-box!
18+
https://docs.avaloniaui.net/docs/getting-started/ide-support
19+
20+
_This screenshot shows the Avalonia design preview in Visual Studio:_
21+
![image](https://user-images.githubusercontent.com/1030435/219173023-a47d5d9b-8926-4f9d-833b-1406661e1c82.png)
622

723
### Benefits
8-
* 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.
1025
* 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
1426
* 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.
1527
* Avalonia already provides first class templates to create an F# project that include creating .axaml views within the same project! (Not possible with WPF!)
1628
* 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.
1729
* The "Avalonia UI for Visual Studio 2022" extension provides a xaml preview pane that works with F#! 😄 (Also not possible with WPF!)
1830
* 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).
1931

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`.
25-
![image](https://github.com/JordanMarr/ReactiveElmish.Avalonia/assets/1030435/00988e96-6905-46fa-9d89-25f7bab6881f)
26-
27-
## ReactiveElmish.Avalonia
28-
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.
33-
34-
![image](https://github.com/JordanMarr/ReactiveElmish.Avalonia/assets/1030435/5278afe4-ce05-4548-b9e9-6a1703394fd7)
35-
36-
37-
### V2 Design Highlights
32+
### Feature Highlights
3833
* 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.)
3934
* 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.
4035
* 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.
4136
* 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!
47-
https://docs.avaloniaui.net/docs/getting-started/ide-support
48-
49-
![image](https://user-images.githubusercontent.com/1030435/219173023-a47d5d9b-8926-4f9d-833b-1406661e1c82.png)
37+
* Built-in dependency injection using `Microsoft.Extensions.DependencyInjection`.
5038

51-
## Runtime View
52-
![image](https://user-images.githubusercontent.com/1030435/219145003-b4168921-ddab-41bc-92ea-d3f432fbc844.png)
5339

5440
# Elmish Stores
5541
ReactiveElmish.Avalonia introduces the `ElmishStore` which is an Rx powered Elmish loop that can be used to power one or more view models.
@@ -59,7 +45,7 @@ This provides flexibility for how you want to configure your viewmodels.
5945
* Some view models may not need a store at all.
6046

6147
## App Store
62-
A global app store can be shared between view models to provide view routing:
48+
A global app store can be shared between view models to, for example, provide view routing:
6349

6450
```F#
6551
module App

0 commit comments

Comments
 (0)