Created
August 8, 2016 18:38
-
-
Save aph5nt/05598cfe59162646dc54f491773474d7 to your computer and use it in GitHub Desktop.
sample amplify w# binding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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