axn is a small (< 1.1 kB minified, ~440 bytes gzipped) implementation of listenable actions or signals in JavaScript.
npm install axn
git clone https://github.com/pluma/axn.git
cd axn
npm install
npm run test && npm run dist
component install pluma/axn
bower install axn
Download the latest minified CommonJS release and add it to your project.
Learn more about CommonJS modules.
Download the latest minified AMD release and add it to your project.
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.
Creates a new action.
If spec
is an object, its properties will be copied to the new action, overwriting its default properties.
Invokes the action's listeners with the given data
.
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.
Removes the given function with the given context from the action's listeners.
Returns true
if the listener was removed successfully, otherwise returns false
.
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.
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.
An object containing the default properties that will be copied to new actions.
The MIT/Expat license. For more information, see http://pluma.mit-license.org/ or the accompanying LICENSE file.