So I have added some data using typeproviders into my applications (github link) So here is the problem.
1) What I wanted is that my Site.fs
use data and build div according to rules I gave it. Everything looks fine except....
I put back end calculation into WebSite project and probably because Web is startup project calculations in WebSite are never done and never pushed on database. It is only displayed data which is already in database.
Plus sometimes there is only ${title}
and body instead of text provided in fsharp (even using default sitelet sample site). Is that normal? Restarting visual studio helps.
P.S.: sorry if my code doesn't look so spectacular I want it to work first and after that I will refactor it.
As you guessed, top-level values (such as your
Site.items
) are computed once at the launch of the application. If you want it to be computed at every page load, it needs to be computed inside the function that receives aContext<Action>
. [1]For example, you can do something like the following:
Here, since
getItems
is a function, it computes its return value every time you ask for it withlet items = getItems()
.[1] You could also do it inside the function passed to
Sitelet.Infer
, if you used it. This would be useful if theContent
you want to return depends onitems
, for example if you wanted to use a different template depending onitems
.