Announcement

Collapse
No announcement yet.

[CLOSED] Retyped.Knockout - Allow observables to be processed as simple types on c#

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

    [CLOSED] Retyped.Knockout - Allow observables to be processed as simple types on c#

    Hello,

    Is it possible to make it so it can detect & "auto" generate code. For instance:

    c#
    using static Retyped.knockout;
    using int_Observable = Retyped.knockout.KnockoutObservable<int>.Interface ;
    
    public class sample
    {
        public int_Observable A { get; set; }
        public int_Observable B { get; set; }
    
        public ChangeA(int_Observable pA)
        {
            //Instead of:
            A.Self(pA.Self());
            B.Self(pA.Self() * 2);
    
            //I could put directly:
            A = pA;
            B = pA * 2;
        }
    }
    And it would generate on JS:

    methods: {
        ChangeA: function (pA) {
            this.A(pA());
            this.B(((pA() * 2) | 0));
        }
    }
    This would be nice for people who are trying to use code sharing between Bridge.NET and pure c#.
    Thanks.
    Last edited by geoffrey.mcgill; 2017-10-23 @ 08:11 PM.

    #2
    Hi joaommvsoares,

    I don't think that incorporating custom logic into Retyped is feasible, at least at the moment. Meanwhile you can create your own wrappers simplifying usage of objects in your scenario. Consider the following sample, hope it helps:

    [External]
    public class MyObservable<T>
    {
        [Template("{this}")]
        public Retyped.knockout.KnockoutObservable<T>.Interface Observable;
    
        [Template("{0}")]
        public extern MyObservable(Retyped.knockout.KnockoutObservable<T>.Interface observable);
    
        public T Value
        {
            [Template("{this}()")]
            get;
    
            [Template("{this}({0})")]
            set;
        }
    }

    Comment

    Working...
    X