Posts

Showing posts from 2015

Single page app with WebSharper UI.Next and Bootstrap

Image
Single page application in F# with WebSharper UI.Next Last week I wrote a post on how I handle latency and exception while interacting with REST api in F# using computation expression and WebSharper . The first part on computation expression was quite detailed but the second part on WebSharper was mostly code snippets with very little explanations. Today I want to rectify that by showing you how I am using WebSharper UI.Next to build a simplistic single page application ( SPA ). Here is the result of what we will do: In this post I will explain few points which were hard for me to grasp when I started to code in F# with WebSharper. By writing this post, I hope that it will help you and that you won’t need to go through the same flip table phase as I did! So put on your seat belt and enjoy the ride. In this post I will explain to you: The basic of UI.Next in order for you to be able to understand the code How I manage routing for the SPA How I split my webapp and organize my c

Computation Expression Approach For Calling Rest Api

Computation expression approach for calling REST API In this post, I will share with you how I handle latency and exception for Ajax calls from a front-end Single page application built in F# with WebSharper. The code is inspired by @ScottWlaschin blog post http://fsharpforfunandprofit.com/posts/elevated-world-5/#asynclist . I will not explain what is a computation expression, for that you can refer to fsharpforfunandprofit computation expressions tutorial and I will not explain how to use WebSharper and UI.Next, for that you can refer to UI.Next samples . What I will explain here is how I combine both; to write simple code without worrying about side-effects. When interacting with REST API from a Single page application, it is a common pattern to: Get an authentication token with a Ajax call Retrieve some JSON data using the token with a Ajax call (again) Deserialize the content from JSON to your local type What we would want to write is (1) let getMyData () = let