Closed valeriy-maslov closed 7 years ago
Oh, it is completely okay. In this situation you should use
PlatypusRPC.requireRemotes(arguments[0], function(aAlreadyInstantiatedProxy){
aAlreadyInstantiatedProxy.someMethod(..., function(){
});
})
method. It will query server for information about server module structure, and then it will instantiate proper proxies and pass them to your callback.
Ok, so my guess was right about it. There is another little question.
Let's say I did Rpc.requireRemotes
for moduleA
. Will Rpc.Proxy('moduleA')
work if I call it somewhere after?
Yes, it will work.
Ok, understood, thanks :)
There is a situation when I need to instantiate
Rpc.Proxy
passing var, not string literal. Like this:This is fails with this error:
Trying to fix this I did some research. So, in usual situations module name passes into
Rpc.Proxy
constructor as string literal. It seems Platypus analyze source code for this stuff and sends HTTP GET request back to server with__type=12
and module name as parameters.This request type is defined like this in Platypus.js sources:
This request is sending rightafter HTML5 client environment starts to load and returns JSON with array list of public methods of module. I assume that this request generated with
Rpc.requireRemotes()
, correct me if I'm wrong.To make this more clear for ya I also explain how this exact situation was reproduced in my code. So, all used modules is client side. There is a module which doing some stuff and must return different module implementations depending on previous results.
Modules A and B have kinda complicated logic :) There is some dynamic properties which actually can be represented as simple JavaScript
Function()
or much more complicatedRpc.Proxy
for some server module. In JS it looks like this:I actually know your next question :)
Why the hell it is so difficult?
Well, the explanation will be too long. So I'll write only one phrase: ass-kicking microservices :)