There is an experimental branch I started some time ago that would allow an even shorter syntax, not even needing a fun () ->, thanks to WebSharper macros. I haven't touched it in a bit, but it looks something like this:

1
2
3
4
5
6
7
8
9
// Usual UI.Next corresponding to your code
let pageStr =
    View.Map2 (fun f p ->
            	"Page " + if f then ".." else p.ToString())
                m.Fetching m.Page

// V version
let pageStr =
    V ("Page " + if m.Fetching.V then ".." else m.Page.V.ToString())

It even makes HTML functions like div and text macros so that you don't need to wrap in a V() when building markup:

1
2
3
4
5
6
7
8
9
10
// Usual UI.Next
let someTextNode : Doc =
    View.Map2 (fun f p ->
        		"Page " + if f then ".." else p.ToString())
                m.Fetching m.Page
    |> textView

// V version
let someTextNode : Doc =
    text ("Page " + if m.Fetching.V then ".." else m.Page.V.ToString())

It doesn't actually dynamically create the dataflow, instead it transforms the code at compile time and generates the same set of Maps, Map2s, etc that you would otherwise write yourself. I hope to have time to go back to it as soon as possible :)

By on 2/1/2017 3:06 AM ()

That's frackin' amazing!

By on 2/8/2017 4:16 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper