
Product
A Fresh Look for the Socket Dashboard
We’ve redesigned the Socket dashboard with simpler navigation, less visual clutter, and a cleaner UI that highlights what really matters.
nodejs-mobile-ipc2
Advanced tools
An abstraction of nodejs-mobile-react-native channels that allows to call functions on the other side and retrieve their results.
An abstraction for nodejs-mobile-cordova and nodejs-mobile-react-native channels that allows you to call functions on the other side and retrieve their results.
npm i nodejs-mobile-ipc2
Create a new NodejsMobileIPC instance:
const ipc = new NodejsMobileIPC(channel);
channel
can be either rnBridge.channel
(in the Node.js project) or nodejs.channel
(in the React Native app).
To provide a function for the other side of the channel use the register
method:
ipc.register('myFunction', (param) => {
return 'You send: ' + param;
});
Then, the other side of the channel can call that function and retrieve its return value by using the call
method:
const result = await ipc.call('myFunction', 'TEST'); // result is 'You send: TEST'
NOTE: For each function name there can only be one handler function registered.
Event handlers can be registered using the on
method.
ipc.on('myEvent', (param1, param2) => {
// Do something here, but do not return a value.
});
They are triggered using the emit
method on the other side:
ipc.emit('myEvent', 'TEST1', 'TEST2');
Unlike call
, emit
will not return a value!
NOTE: In contrast to functions, there can be multiple handler registered for an event.
const rnBridge = require('rn-bridge');
const NodejsMobileIPC = require('nodejs-mobile-ipc2').NodejsMobileIPC;
const ipc = new NodejsMobileIPC(rnBridge.channel);
ipc.register('myFunction', (param) => {
return 'You send: ' + param;
});
import { NodejsMobileIPC } from 'nodejs-mobile-ipc2';
const ipc = new NodejsMobileIPC(nodejs.channel);
(async () => {
try {
const result = await ipc.call('myFunction', 'TEST');
console.log(result); // prints 'You send: TEST'
} catch (e) {
console.error('Failed to call');
}
})();
FAQs
An abstraction of nodejs-mobile-react-native channels that allows to call functions on the other side and retrieve their results.
The npm package nodejs-mobile-ipc2 receives a total of 72 weekly downloads. As such, nodejs-mobile-ipc2 popularity was classified as not popular.
We found that nodejs-mobile-ipc2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We’ve redesigned the Socket dashboard with simpler navigation, less visual clutter, and a cleaner UI that highlights what really matters.
Industry Insights
Terry O’Daniel, Head of Security at Amplitude, shares insights on building high-impact security teams, aligning with engineering, and why AI gives defenders a fighting chance.
Security News
MCP spec updated with structured tool output, stronger OAuth 2.1 security, resource indicators, and protocol cleanups for safer, more reliable AI workflows.