fable-compiler / fable-arch

Framework for building applications based on the elm architecture.
https://fable-compiler.github.io/fable-arch/
Apache License 2.0
60 stars 14 forks source link

Support VirtualDom widgets #81

Open fsoikin opened 7 years ago

fsoikin commented 7 years ago

As Fable.Arch stands today, there is no way to spin up external code, other than hacking around with element IDs and whatnot. No escape hatch. VirtualDom has such escape hatch in the form of Widgets. I propose to add support for them to Fable.Arch's VirtualDom renderer.

I see an API along these lines:

let myView model =
    div [classy "my-component-wrapper"] 
        [Widget {
            init = fun handler -> 
                let element = Browser.document.createElement "div"
                let comp = SuperAwesomeExternalComponent.create element
                comp.onSomeEvent (fun e -> handler e.someData)
                element
            update = fun h e -> 
                null 
        } ]

The implementation seems not complicated at all. I have a working prototype that I can clean up and submit as a PR.