Prim+RPC allows functions on the server to be called from the client. This is possible because all function calls are captured on the client, processed on the server, and sent back to the client. But there are some limitations.
All functions on the server, whether async or not, are considered async on the client and type definitions will reflect that your function results are wrapped in a Promise. This is because while it appears that you are calling the function directly, your function is being requested from another environment where it may take time to receive the result (for example, over a network) or that result may not be received in some circumstances (i.e. when network access is lost).
It’s also worth noting that if your function is requested over a network and the network is lost, your client’s method plugin may error. The thrown error will be forwarded to your function’s caller. This is the default behavior of client-side plugins unless you enable options to silence the error or repeat the request on a failure.
Since function calls are not answered on the same client and must be sent somewhere else, the data passed to and received from functions must be serializable by your chosen JSON handler. Most of the time, this will be the JSON object (or structured cloning, if used with Web Workers) unless you choose to override it in Prim+RPC’s options.
Prim+RPC sets the context of your function, the
this object, to your chosen handler’s context. This allows
server-specific details to be passed to your function easily and optionally.
However it means that methods on an instantiated object may not be called directly without potential errors. The easy workaround for this is to wrap your method in another function. The wrapper function will have the server’s context and the contained function will keep its original context.
This behavior may change prior to official release. If the behavior is changed then the original context will be
kept by default unless server context is explicitly set on your chosen handler (currently the context is
not explicitly set from the server).
Prim+RPC is currently in prerelease mode and some features are intended to be supported but are not yet implemented:
There are also some features that won’t be available in the first official release:
It is still possible that these features will be added in the future but since these features are difficult to support, unlikely to be used, and Prim+RPC is gearing up for a stable release, they are considered low priority for version one.Report an Issue