Skip to content

Instantly share code, notes, and snippets.

View lukaszkrzywizna's full-sized avatar

Łukasz Krzywizna lukaszkrzywizna

View GitHub Profile
@lukaszkrzywizna
lukaszkrzywizna / srtp_net6.fs
Last active April 20, 2023 20:44
SRTP F# .Net 6
type MyType =
| MyCase
static member statFun x = match x with MyCase -> "I'm static member function!"
static member statFunUnit () = "I'm static member function with unit param!"
static member statFunGeneric (x, y) =
match x with MyCase -> $"I'm static member function with generic param with value = %O{y}!"
static member statProp = "I'm static member property!"
member this.objProp = match this with MyCase -> "I'm object member property!"
member this.objFunGen x = match this with MyCase -> $"I'm object member function with param with value = %O{x}!"
member this.objFunUnit () = match this with MyCase -> "I'm object member function with unit param!"
@lukaszkrzywizna
lukaszkrzywizna / memo_are-equals.fs
Created March 10, 2023 07:59
ReactMemoAttribute_are-equals
// Attribute can only use local functions so for the outsides ones, the binding is needed
let eq x y = Fable.React.Helpers.equalsButFunctions x y
[<ReactMemoComponent(memoAreEqual=nameof eq)>]
let MyFunc (txt: string) (number: int) = Html.div [ Html.h1 number; Html.p txt ]
{
"includeLanguages": {
"ftl": "html",
"jinja": "html",
"jinja2": "html",
"smarty": "html",
"tmpl": "gohtml",
"cshtml": "html",
"vbhtml": "html",
"razor": "html",
[<Erase>]
type IProp<'comp when 'comp : not struct> = | Prop of string * obj
with
static member inline Create (value: string * obj) = Prop value
static member inline Build(props: IProp<'comp> seq) = props |> unbox<(string * obj) seq> |> createObj |> unbox<'comp>
let inline (!<) x = IProp.Build x
module Interop =
let inline mkProperty<'Component when 'Component : not struct> (key:string) (value:obj) : IProp<'Component> =
module Operators
open Feliz
let inline (+@) (tag: IReactProperty list -> ReactElement) (className: string) (props: IReactProperty list) =
tag (props @ [ prop.className className ])
let inline (++) (tag: IReactProperty list -> ReactElement) (prop: IReactProperty) (props: IReactProperty list) =
tag [prop; yield! props ]
[<Interface>]
type HTMLAttributes<'element when 'element :> Element and 'element :> EventTarget> =
inherit AriaAttributes
inherit DOMAttributes<'element>
abstract member defaultChecked: bool option with get, set
[<Interface>]
type HTMLAttributesFactory<'Property, 'element when
'Property :> HTMLAttributes<'element> and