Package Exports
- sync-rpc
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sync-rpc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
sync-rpc
Run asynchronous commands synchronously by putting them in a separate process
Installation
npm install sync-rpc --saveUsage
worker.js
function init(connection) {
// you can setup any connections you need here
return function (message) {
// Note how even though we return a promise, the resulting rpc client will be synchronous
return Promise.resolve('sent ' + message + ' to ' + connection);
}
}
module.exports = init;const assert = require('assert');
const rpc = require('sync-rpc');
const client = rpc(__dirname + '/../test-worker.js', 'My Server');
const result = client('My Message');
assert(result === 'sent My Message to My Server');License
MIT