Open Silentdoer opened 4 years ago
It's not impossible, but it's not something that is part of our short- or medium-term plans.
Dart has noSuchMethod
which allows you to statically create a proxy for any type as:
class FooProxy imlements Foo {
final dynamic Function(Invocation) _handler;
FooProxy(this._handler);
noSuchMethod(i) => _handler(i);
}
It is not possible to create a dynamic proxy where the type is not known until run-time.
It requires the platform to be able to dynamically create something like the class of FooProxy
, on request, most likely based on a type variable.
Example API:
external T dynamicProxy<T>(dynamic Function(Invocation) handler);
If the dynamicProxy also supports function types, then it would be extra useful.
Like java's Proxy, it is useful for some framework achieve