10

Github GitHub - fsprojects/Avalonia.FuncUI: Develop cross-plattform MVU GUI Appl...

 3 years ago
source link: https://github.com/fsprojects/Avalonia.FuncUI
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Avalonia FuncUI

Develop cross-platform MVU GUI Applications using F# and Avalonia!

(Application was created using Avalonia.FuncUI!)

About

This library allows you to write cross-platform GUI Applications entirely in F# - No XAML, but a declarative Elm-like DSL. MVU (Model-View-Update) architecture support is built in, and bindings to use it with Elmish are also ready to use.

Getting started

Contributing

Please contribute to this library through issue reports, pull requests, code reviews, documentation, and discussion.

Example

Below is the code of a simple counter app (using the Avalonia.FuncUI.Elmish package).

module Counter =

    type CounterState = {
        count : int
    }

    let init = {
        count = 0
    }

    type Msg =
    | Increment
    | Decrement

    let update (msg: Msg) (state: CounterState) : CounterState =
        match msg with
        | Increment -> { state with count =  state.count + 1 }
        | Decrement -> { state with count =  state.count - 1 }
    
    let view (state: CounterState) (dispatch): IView =
        DockPanel.create [
            DockPanel.children [
                Button.create [
                    Button.onClick (fun _ -> dispatch Increment)
                    Button.content "click to increment"
                ]
                Button.create [
                    Button.onClick (fun _ -> dispatch Decrement)
                    Button.content "click to decrement" 
                ]
                TextBlock.create [
                    TextBlock.dock Dock.Top
                    TextBlock.text (sprintf "the count is %i" state.count)
                ]
            ]
        ]    

Maintainer(s)

The default maintainer account for projects under "fsprojects" is @fsprojectsgit - F# Community Project Incubation Space (repo management)


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK