Prototype MVC (or MVI) client-side with RxJS and D3 to show use with various component libraries.
At present, RxJS Subjects are used as part of an inheritance hierarchy.
A Pen by Ryan Riley on CodePen.
| open Newtonsoft.Json | |
| let serializerSettings = JsonSerializerSettings(ContractResolver = Serialization.CamelCasePropertyNamesContractResolver()) | |
| serializerSettings.Converters.Add(OptionConverter()) | |
| let serialize data = | |
| JsonConvert.SerializeObject(data, serializerSettings) | |
| |> Text.Encoding.UTF8.GetBytes | |
| let deserialize<'T> (stream: Stream) = |
| (** | |
| * Handlers | |
| *) | |
| let notFound (env: OwinEnv) = | |
| env.[Constants.responseStatusCode] <- 404 | |
| env.[Constants.responseReasonPhrase] <- "Not Found" | |
| async.Return() | |
| let methodNotAllowed (env: OwinEnv) = |
| (** | |
| * Routing | |
| *) | |
| let matchUri template env = | |
| let environ = Environment.toEnvironment env | |
| let basePath = environ.RequestPathBase | |
| let template' = if String.IsNullOrEmpty basePath then template else basePath + template | |
| let uriTemplate = UriTemplate(template', ignoreTrailingSlash = true) | |
| let baseUri = |
| open System.Collections.Generic | |
| open Microsoft.FSharp.Collections | |
| [<RequireQualifiedAccess>] | |
| module Folds = | |
| // These are the fast implementations we actually want to use |
| // F# equivalent of ML signatures? | |
| type MSIG = | |
| interface | |
| // Cannot embed type signatures. | |
| //type key | |
| abstract x : int | |
| end | |
| // F# equivalent of ML structures? | |
| type M = |
| using NancyFx.Resource; | |
| public class MyResource : ResourceModule | |
| { | |
| public MyResource("/", { | |
| Get = () => ... | |
| }) | |
| } |
| type SampleResourceMethod = | |
| | Create of AsyncReplyChannel<unit> | |
| | SetTimestamp of DateTimeOffset * AsyncReplyChannel<unit> | |
| type SampleResource() = | |
| let agent = MailboxProcessor<_>.Start(fun inbox -> | |
| let rec loop () = async { | |
| let! msg = inbox.Receive() | |
| match msg with | |
| | Create ch -> |
Prototype MVC (or MVI) client-side with RxJS and D3 to show use with various component libraries.
At present, RxJS Subjects are used as part of an inheritance hierarchy.
A Pen by Ryan Riley on CodePen.
Prototype MVC (or MVI) client-side with RxJS and D3 to show use with various component libraries.
At present, RxJS Subjects are used like channels and not as part of an inheritance hierarchy.
A Pen by Ryan Riley on CodePen.
| (function (global, Data, Nav, f) { | |
| f(global, Data, Nav); | |
| })(window, window.Data, window.Nav, | |
| function app(global, data, Nav) { | |
| "use strict"; | |
| var nav = Nav("nav.nav"); | |
| nav(data); | |
| global.setTimeout(function () { |