Home

Awesome

Elmish.Toastr Build Status Build status Nuget

Toastr integration with Fable, implemented as Elmish commands.

Live Demo Application with Examples

Installation

paket add nuget Elmish.Toastr --project /path/to/Project.fsproj
npm install toastr --save
npm install css-loader style-loader --save-dev
{
    test: /\.(sa|c)ss$/,
    use: [
        "style-loader",
        "css-loader"
    ]
}

Usage

See the demo app for reference. Create toastr commands and use them in the Elmish dispatch loop

open Elmish
open Elmish.Toastr

type Msg = 
    | ShowSuccess
    | Clicked
    | Closed

let successToast : Cmd<Msg> = 
    Toastr.message "Success message"
    |> Toastr.title "Shiny title"
    |> Toastr.position TopRight
    |> Toastr.timeout 3000
    |> Toastr.withProgressBar
    |> Toastr.hideEasing Easing.Swing
    |> Toastr.showCloseButton
    |> Toastr.closeButtonClicked Closed
    |> Toastr.onClick Clicked 
    |> Toastr.success

let update msg model = 
    match msg with
    | ShowSuccess -> 
        model, successToast

    | Clicked ->
        let infoToast = 
            Toastr.message "You clicked previous toast"
            |> Toastr.title "Clicked"
            |> Toastr.info
        model, infoToast

    | Closed ->
        let infoToast = 
            Toastr.message "You clicked the close button"
            |> Toastr.title "Close Clicked"
            |> Toastr.info
        model, infoToast
    | _ -> 
        model, Cmd.none