Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@capacitor/synapse

Package Overview
Dependencies
Maintainers
10
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capacitor/synapse

### Example

npmnpm
Version
1.0.2
Version published
Weekly downloads
313K
11.47%
Maintainers
10
Weekly downloads
 
Created
Source

Synapse

Example

You have plugins that exist for both Capacitor and Cordova. They share the same API for the most part; as in they both expose a ping method that takes a string and returns that string with the word "_pong" appeneded to it. You can use synapse to create a single call in ODC that will use which ever plugin is available to the built app. Adding this to your plugins does not alter their ability to be used in the normal fashion they would be directly in a Capacitor or Cordova app.

Capacitor Usage of MyPlugin

import { MyPlugin } from 'capacitor-my-plugin';
...
async function buttonClick() {
  try {
    const resp = await MyPlugin.ping({text: "Hello World"});
    console.log(resp); // "Hello World_pong"
  } catch (error) {
    console.error(error);
  }
}

Cordova Usage of MyPlugin

function buttonClick() {
  window.cordova.plugins.MyPlugin.ping(
    {text: "Hello World"},
    function(response) {
      console.log(response); // "Hello World_pong"
    },
    function(error) {
      console.error(error);
    }
  )
}

Synapse Usage of MyPlugin

function buttonClick() {
  window.CapacitorUtils.Synapse.MyPlugin.ping(
    {text: "Hello World"},
    function(response) {
      console.log(response); // "Hello World_pong"
    },
    function(error) {
      console.error(error);
    }
  )
}

While similar to the way you call cordova plugins, the synapse call will use the appropriate plugin for the platform it is running on. If the app is built with Capacitor, it will use the Capacitor plugin. If the app is built with Cordova, it will use the Cordova plugin.

FAQs

Package last updated on 19 Feb 2025

Did you know?

Socket

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.

Install

Related posts