Skip to content

Instantly share code, notes, and snippets.

@aph5nt aph5nt/amplify.fs
Created Aug 8, 2016

Embed
What would you like to do?
sample amplify w# binding
namespace Amplify
open WebSharper
open WebSharper.JavaScript
open WebSharper.InterfaceGenerator
open WebSharper.JQuery
module Definition =
let DefineRequestType =
"ajax".Split ' ' |> Pattern.EnumStrings "DefineRequestType"
let RequestSettings =
Pattern.Config "RequestSettings" {
Required =
[
"resourceId" , T<string>
]
Optional =
[
"data", T<obj>
"success" , (T<obj>?data ^-> T<unit>)
"error" , (T<string>?status * T<string>?xhr ^-> T<unit>)
]
}
let Request =
Class "Request"
|+> Static [
"Define" => ( T<string>?resourceId * DefineRequestType?requestType * T<AjaxSettings>?settings ^-> T<unit> )
]
let Amplify =
Class "Amplify"
|+> Static [
"Request" => (RequestSettings?settings ^-> T<unit>)
"Request" => (T<string>?resourceId * T<Object<string>>?data * (T<obj> ^-> T<unit>)?callback ^-> T<unit>)
"Define" => ( T<string>?resourceId * DefineRequestType?requestType * T<AjaxSettings>?settings ^-> T<unit> )
]
|=> Nested [ Request ]
let Assembly =
Assembly [
Namespace "WebSharper.Amplify" [
Amplify
RequestSettings
DefineRequestType
]
Namespace "WebSharper.Amplify.Resources" [
Resource "Amplify" "https://cdnjs.cloudflare.com/ajax/libs/amplifyjs/1.1.2/amplify.core.js"
|> fun r -> r.AssemblyWide()
]
]
[<Sealed>]
type Amplify() =
interface IExtension with
member ext.Assembly =
Definition.Assembly
[<assembly: Extension(typeof<Amplify>)>]
do ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.