New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

choo-trigger

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

choo-trigger

Chain emitters together

  • 1.0.1
  • latest
  • npm
  • Socket score

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

choo-trigger

API stability NPM version Build Status Standard

Set up an event to be emitter after another event has been emitted. This allows you to chain events in series from a view to create ad-hoc workflows for your application. Triggers are attached via .once so after they are fired, they are removed from the emitter.

API

emit('trigger:create', opts:object(key:string))

Create a listener using .once for a specific event, and then fire an event in response to it.

  • opts:
    • on:string - event name to listen for
    • event:string - event name to fire
    • data:any - data to include with the event being emitted

Usage

var choo = require('choo')
var trigger = require('choo-trigger')
var app = choo()
app.use(trigger)
app.use(store)
app.route('/', main)
document.body.appendChild(app.start())

function store (state, emitter) {
  state = {
    trigger: false,
    hello: 'no one'
  }

  emitter.on('runTrigger', (opts) => {
    state.trigger = true
    state.hello = opts.hello
    emitter.emit('render')
  })
}

function main (state, emit) {
  emit('trigger:create', {on: 'go', event: 'runTrigger', data: {hello: 'world'}})

  return html`<div>
    triggered? ${state.trigger}<br>
    hello, ${state.hello}
    <button onclick=${run}>send trigger!</button>
  </div>`

  function run (evt) {
    evt.preventDefault()
    emit('go')
  }
}

License

Copyright © 2017 Todd Kennedy, Apache-2.0 Licensed

Keywords

FAQs

Package last updated on 15 Jun 2017

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