Socket
Socket
Sign inDemoInstall

axn

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    axn

Minimalist listenable actions.


Version published
Weekly downloads
11
increased by266.67%
Maintainers
1
Install size
25.7 kB
Created
Weekly downloads
 

Readme

Source

Synopsis

axn is a small (< 1.1 kB minified, ~440 bytes gzipped) implementation of listenable actions or signals in JavaScript.

license - MIT Dependencies

NPM status

browser support

Build Status Coverage Status

Install

Node.js

With NPM

npm install axn

From source

git clone https://github.com/pluma/axn.git
cd axn
npm install
npm run test && npm run dist

Browser

With component

component install pluma/axn

Learn more about component.

With bower

bower install axn

Learn more about bower.

With a CommonJS module loader

Download the latest minified CommonJS release and add it to your project.

Learn more about CommonJS modules.

With an AMD module loader

Download the latest minified AMD release and add it to your project.

Learn more about AMD modules.

As a standalone library

Download the latest minified standalone release and add it to your project.

<script src="/your/js/path/axn.globals.min.js"></script>

This makes the axn module available in the global namespace.

API

axn([spec]):Function

Creates a new action.

If spec is an object, its properties will be copied to the new action, overwriting its default properties.

action(data)

Invokes the action's listeners with the given data.

action.listen(fn, [ctx]):Function

Adds a given function to the action's listeners. If ctx is provided, the function will be invoked using it as its this context.

Returns a function that will remove the listener from the action.

action.unlisten(fn, [ctx]):Boolean

Removes the given function with the given context from the action's listeners.

Returns true if the listener was removed successfully, otherwise returns false.

action.beforeEmit(data):data

Override this function in your action's spec to pre-process data passed to the action before it is emitted.

The return value will be passed to the action's listeners.

action.shouldEmit(data):Boolean

Override this function in your action's spec to define whether data should be emitted.

This function is passed the output of beforeEmit. If the function returns false or a non-truthy value, the data will not be emitted. Otherwise the action's listeners will be invoked as normally.

axn.methods

An object containing the default properties that will be copied to new actions.

License

The MIT/Expat license. For more information, see http://pluma.mit-license.org/ or the accompanying LICENSE file.

Keywords

FAQs

Last updated on 09 Dec 2014

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc