Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@agent/walkie-talkie

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agent/walkie-talkie

> Communicate Between React Native Web Views and Mobile Web Apps

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
2
Weekly downloads
 
Created
Source

Walkie Talkie

Communicate Between React Native Web Views and Mobile Web Apps

npm i @agent/walkie-talkie

Usage in Native

import { NativeWalkieTalkie } from '@agent/walkie-talkie'

const walkieTalkie = new NativeWalkieTalkie({ logs: true })

walkieTalkie.onMessages(async (message) => {
    switch (message.type) {
        case 'NATIVE/ALERT': {
            return await new Promise((resolve, reject) => {
                Alert.alert(
                    message.message,
                    '',
                    [
                        {text: 'Yes', onPress: () => resolve(message)},
                        {text: 'No', onPress: reject},
                    ]
                )
            })
        }
        default:
            return message
    }

})

Usage in Web

import { WebWalkieTalkie } from '@agent/walkie-talkie'

const walkieTalkie = new WebWalkieTalkie({ logs: true })

walkieTalkie.onReady(() => {
    walkieTalkie.send({ type: 'NATIVE/ALERT', message: 'Hello from Web' })
        .then(() => walkieTalkie.sendLog('accepted alert'))
        .catch(() => walkieTalkie.sendLog('rejected alert'))
})

// This will be inside a middleware so it can dispatch.
walkieTalkie.onMessages((message) => {
    switch (message.type) {
        case 'NOTIFICATION':

            dispatch(actions.showNotification({ message }))

            return {
                ...message,
                testing: 123,
            }
        default:
            return message
    }

})

Methods

  • onReady(cb) callback fires when each bridge is ready
  • onMessages(cb) callback fires whenever there is a message from the other bridge
  • send(action) send an action to the other bridge

FAQs

Package last updated on 19 Dec 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc