Информация об изменениях

Сообщение Re: Angular 2 и .Net Core от 04.01.2017 13:50

Изменено 05.01.2017 10:56 Serginio1

Re: Angular 2 и .Net Core
Здравствуйте, Serginio1, Вы писали:
Будем продвигаться потихоньку.
в ECMAScript 6 появились Динамические прокси
Это аналог DynamicObject.

Кроме свойств, можно вызвать метод

Remote objects

Proxies allow you to create virtual objects that represent remote or persisted objects. To demonstrate this, let's write a wrapper around an existing library for remote object communication in Javascript. Tyler Close's web_send library can be used to construct remote references to server-side objects. One can then "invoke" methods on this remote reference via HTTP POST requests. Unfortunately, remote references cannot be used as objects themselves. That is, to send a message to a remote reference ref, one writes:


Q.post(ref, 'foo', [a,b,c]);
It would be a lot more natural if one could instead treat ref as if it were an object, such that one could call its methods as ref.foo(a,b,c). Using the Proxy API, we can write a wrapper for remote web_send objects to translate property access into Q.post calls:

function Obj(ref) {

  return Proxy.create({

    get: function(rcvr, name) {

      return function() {

        var args = Array.prototype.slice.call(arguments);

        return Q.post(ref, name, args);

      };

    }

  });

}

Now one can use the Obj function to write Obj(ref).foo(a,b,c).


Прокси-объект (JavaScript)

Так понимаю, что можно сцепить и с apply https://learn.javascript.ru/proxy
То есть узнать, что вызывается метод, можно только по arguments?

Хотя можно использовать noSuchMethod

Из Native Client Messaging System

Можно обмениваться через сообщения. Впринципе можно организовать вызов через аналог ContinueWith.
Или можно вызвать метод синхронно?
javascript typescript angular2 .net core
Re: Angular 2 и .Net Core
Здравствуйте, Serginio1, Вы писали:
Будем продвигаться потихоньку.
в ECMAScript 6 появились Динамические прокси
Это аналог DynamicObject.

Кроме свойств, можно вызвать метод

Remote objects

Proxies allow you to create virtual objects that represent remote or persisted objects. To demonstrate this, let's write a wrapper around an existing library for remote object communication in Javascript. Tyler Close's web_send library can be used to construct remote references to server-side objects. One can then "invoke" methods on this remote reference via HTTP POST requests. Unfortunately, remote references cannot be used as objects themselves. That is, to send a message to a remote reference ref, one writes:


Q.post(ref, 'foo', [a,b,c]);
It would be a lot more natural if one could instead treat ref as if it were an object, such that one could call its methods as ref.foo(a,b,c). Using the Proxy API, we can write a wrapper for remote web_send objects to translate property access into Q.post calls:

function Obj(ref) {

  return Proxy.create({

    get: function(rcvr, name) {

      return function() {

        var args = Array.prototype.slice.call(arguments);

        return Q.post(ref, name, args);

      };

    }

  });

}

Now one can use the Obj function to write Obj(ref).foo(a,b,c).


Прокси-объект (JavaScript)

Так понимаю, что можно сцепить и с apply https://learn.javascript.ru/proxy
То есть узнать, что вызывается метод, можно только по arguments?
Или использовать ]__noSuchMethod__ [/url<br />
<br />
Хотя можно использовать [url=https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/noSuchMethod]noSuchMethod


Из Native Client Messaging System

Можно обмениваться через сообщения. Впринципе можно организовать вызов через аналог ContinueWith.
Или можно вызвать метод синхронно?
javascript typescript angular2 .net core