Where can I find the OnAfterRender function referenced in WebSharper code?

319 Views Asked by At

I've just started using WebSharper, and I'm trying to do something with the Google Maps API. I have been trying to implement the sample code from below: https://github.com/intellifactory/WebSharper.Google.Maps

open IntelliFactory.WebSharper.Google

[<JavaScript>]
let Sample buildMap =
    Div [Attr.Style "padding-bottom:20px; width:500px; height:300px;"]
    |>! OnAfterRender (fun mapElement ->
        let center = new Maps.LatLng(37.4419, -122.1419)
        let options = new Maps.MapOptions(center, MapTypeId.ROADMAP, 8)
        let map = new Maps.Map(mapElement.Dom, options)
        buildMap map)

But I can't find where the OnAfterRender method lives. I believe I've opened all the required namespaces, but there is no mention of it.

A cheap second question, is there a best database to use with WebSharper apps, or does it make no difference? Appharbor gives me the choice of: RavenDB, Microsoft SQL Server, MySQL, ElephantSQL, JustOneBD and MongoDB. I've got very little db experience, and I only need a very simple flatfile db.

1

There are 1 best solutions below

2
Ramon Snir On BEST ANSWER

OnAfterRender is defined in IntelliFactory.WebSharper.Html.Operators (as can be seen from here). It is sufficient to open IntelliFactory.WebSharper.Html (as Operators is marked with [<AutoOpen>]).


Regarding the database, there is nothing too important here. What you should make sure you have, before you make the decision, is:

  1. A .Net interface (usually exists, especially if AppHarbor offers that database)

  2. A good ORM that generates F#-usable classes. The definition of "F#-usable" is of course subjective, but make sure that the classes fits your coding style, otherwise you'll have to write your own ORM or your own wrappers around the ORM classes.

Related Questions in F#