WebSharper

The following code works as long as current is equal to "a" or "b":

1
2
3
4
5
6
7
8
let snippets    = ListModel.Create id [ "a" ; "b" ]
let current     = Var.Create "a"
let currentOf k = snippets.LensInto id (fun s n -> n) k

div [
        Doc.Input [] current                                                     
        current.View |> Doc.BindView (fun cur ->  Doc.Input [] (currentOf cur))  
] |> Doc.RunById "tasks"

... when current is different it throws:

1
2
3
4
5
6
7
8
9
10
11
WebSharper: Uncaught asynchronous exception TypeError: Cannot read property '$0' of null
    at a (WebSharper.UI.Next.js:1961)
    at WebSharper.UI.Next.js:849
    at Object.Snap.When (WebSharper.UI.Next.js:957)
    at Object.Snap.Map (WebSharper.UI.Next.js:844)
    at Object.o (WebSharper.UI.Next.js:1581)
    at WebSharper.UI.Next.js:1595
    at Object.o (WebSharper.UI.Next.js:1580)
    at WebSharper.UI.Next.js:1595
    at Object.o (WebSharper.UI.Next.js:1580)
    at WebSharper.UI.Next.js:1595
  • loic.denuziere

    Yes it would be useful to provide partial lenses, ie. lenses that return an IRef<option<'T>>.