🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

proxy-trigger

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proxy-trigger

Proxies events from one emitter to another.

latest
Source
npmnpm
Version
2.0.4
Version published
Maintainers
1
Created
Source

proxy-trigger

es6 js-standard-style CircleCI

Proxies ampersand-events or Backbone.Events from one emitter to another.

A note about compatibility

The npm package should be used in an ES6 environment. Even though the published code has ES5 syntax it uses some ES6 features, so you have to make sure to use ES5 and ES6 polyfills if you are in an ancient environment.

Install

npm install proxy-trigger

Usage

import proxyTrigger from 'proxy-trigger'

// proxy all events by default
proxyTrigger(sourceEmitter, targetEmitter)
targetEmitter.on('foo bar', (msg) => console.log(msg))
sourceEmitter.trigger('foo', 'proxied foo')
sourceEmitter.trigger('bar', 'proxied bar')
// -> proxied foo
// -> proxied bar

// proxy a single event
proxyTrigger(sourceEmitter, targetEmitter, 'change:title')
targetEmitter.on('change:title', () => console.log('title changed'))
sourceEmitter.trigger('change:title')
// -> title changed

// proxy multiple events with a space-separated string
proxyTrigger(sourceEmitter, targetEmitter, 'open close')

// proxy multiple events with an array of strings
proxyTrigger(sourceEmitter, targetEmitter, ['open', 'close'])

// proxy events with name mapping using object notation
proxyTrigger(sourceEmitter, targetEmitter, {'change:title': 'change:source.title'})

// everything mixed
proxyTrigger(sourceEmitter, targetEmitter, [
  'open close', {'change:title': 'change:source.title'}
])

Mixin usage

import {mixin as proxyTriggerMixin} from 'proxy-trigger'
import View from 'ampersand-view'

export default View.extend(proxyTriggerMixin, {
  initialize () {
    this.proxyTrigger(this.someSubView, 'close')
  },
  ...
})

Test

npm test

License

MIT

Keywords

proxy

FAQs

Package last updated on 23 Jul 2019

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