No announcement yet.

Problem with Script.Get

  • Filter
  • Time
  • Show
Clear All
new posts

    Problem with Script.Get

    Hi, Im looking into Bridge.NET

    I try to bridge a third party JS library.

    Here is my test code

        public static class Ko
            public delegate T ObservableDelegate<T>(T value = default(T));
            public static ObservableDelegate<T> Observable<T>(T value)
                var observable = Script.Get<Func<T, ObservableDelegate<T>>>("ko.observable");
                return observable(value);
        public class App
            public static void Main()
                var observable = Ko.Observable("value");
    This gives expcetion

    Uncaught TypeError: Converting circular structure to JSON
    at JSON.stringify (<anonymous>)
    at Function.logBase (bridge.console.js:95)
    at Function.log (bridge.console.js:129)
    at Function.System.Console.WriteLine (bridge.console.js:47)
    at Function.Main (App.cs:33)
    at bridge.js:3321
    at HTMLDocument.delayfn (bridge.js:595)
    at HTMLDocument.listenHandler (bridge.js:615)

    What am I doing wrong?
    Last edited by AndersMalmgren; 2019-03-10 @ 04:29 PM.

    This works!

        public static class Ko
            public delegate T ObservableDelegate<T>(T value = (dynamic)null);
            public extern static void ApplyBindings<TMOdel>(TMOdel model);
            public extern static ObservableDelegate<T> Observable<T>(T value = default(T));


      I lied. IT does not work.

      this.Foo() which should just return the value of the observables instead does

      this.Foo(void 0)
      Which breaks. Can I tell Bridge to just call it without parameters somehow?


        This could have worked,
                public delegate T ObservableDelegate<T>(params T[] value);
        But expand params does nto seem to do what teh docs suggset, since the rsulting javascript is

        Which is not what I am after


          you could use below: it will be like you wrote the javascript.

          insert javascript here.            


            Hello AndersMalmgren, and welcome to Bridge forums!

            To make Bridge call it without parameters you should just remove the {0} bit from the template. It would probably help reading the wiki entry we have for the template attribute:

            Hope this helps!