Announcement

Collapse
No announcement yet.

Bridge.jQuery2 Deferred.Done()

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Bridge.jQuery2 Deferred.Done()

    Hello Bridge.Net,

    I am struggling with jQuery2 Deferred and the Done/Fail calls with Lambda expressions.

    I am missing some template functions for Done ( and other functions of Bridge.jQuery2 returning a Deferred object).

    It would be handy to have template functions like:
    public virtual Deferred Done<T>(params Action<T>[] doneCallbacks)

    Here is code snipped for testing (I have tested in the Deck)

    using Bridge;
    using Bridge.Html5;
    using Bridge.jQuery2;
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace TestDeferred
    {
       //Dummy
       public static class Test
        {
            public static Deferred Get()
            {
                return null;
            }
        }
        
         public static class TestCase
        {
             //ok
            public static void Test1()
            {
                Test.Get().Done( () =>
                 {
    
                 });
            }
            
                      
            //ok
            public static void Test2()
            {
                  Action<string> f = (s) =>
                  {
                      int l = s.Length;
                  };
                  
                Test.Get().Done( f);
            }
            
           //is indeed never ok (type is unknown)
            public static void Test3()
            {
                Test.Get().Done( (s) =>
                  {
                      int l = s.Length;
                  });
            }
    
             //not ok!?
            public static void Test4()
            {
                Test.Get().Done( ( string s) =>
                  {
                      int l = s.Length;
                  });
            }
    
           //would like to do this!?
            public static void Test5()
            {
                Test.Get().Done<string>( (s) =>
                  {
                      int l = s.Length;
                  });
            }
        }
        
    }

    if I add the following extension dummy, then it works? (except for Test3 which is ok)


     [External]
        public static class Tst
        {
            public static Deferred Done<T>(this Deferred d, params Action<T>[] doneCallbacks )
            {
                return d.Done(doneCallbacks);
            }
        }
    Last edited by guidovanhils; 2017-01-22 @ 10:33 PM.
Working...
X