Hello!

This is a WIG suitable descriptor for your JS "class":

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
let TestObj =
    Class "testobj"
    |> WithSourceName "TestObj" // capitalize .NET name
    |+> Instance [
            // Read-write properties, use =? for read-only
            "aval" =@ T<int> 
            "bval" =@ T<int>
            // methods
            "add" => T<unit> ^-> T<int>
            "mult" => T<unit> ^-> T<int>
            "subs" => T<unit> ^-> T<int>
        ]
    |+> Static [
            // actually constructors are ok to include in the Instance list too
            // then the Static part can be dropped
            Constructor (T<int> * T<int>)
        ]

The https://github.com/dotnet-websharper/ org contains many examples of WIG bindings. Hope this helps!

By on 12/20/2019 6:28 AM ()

Thank you JankoA.

How i can handle "objectles" callbacks?

I want to use this lib: https://github.com/softwaretailoring/wheelnav/releases.

For example an class has a property to asign an function -> spreaderPathFunction. All the functions are defined in the js file, but not as prototype:

1
2
this.PieSpreader = function (helper, percent, custom) { ...}
this.StarSpreader = function (helper, percent, custom){...}

Helper is defined as

1
2
3
4
5
 Percent is an float and
 custom is defined as  ````var slicePathCustomization = function ()````

I tryed to define 
the args:
1
2
3
4
5
6
7
8
9
10
    Class "pathHelper"
    |> WithSourceName "PathHelper"
    |+> Static [
        Constructor (T<unit> )
     ]
let PieSliceCustomization = 
    Class "PieSliceCustomization"
    |+> Static [
        Constructor (T<unit> )
     ]
1
the property:

"spreaderPathFunction" =@ ( PathHelper T<float> PieSliceCustomization ^-> T<obj>)

1
2
3
4
Is this correct?

How i handle all the this.xxxSpreader functions?
By on 1/2/2020 8:32 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper