Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Hudkit actions
JavaScript
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
.gitignore
README.md
index.js
package.json

README.md

hudkit-action

An action is a wrapped, observable function that can be enabled/disabled. Actions are called just like normal functions but act as no-ops when disabled.

Note: this module was written for hudkit but can also be used in isolation.

Install

$ npm install hudkit-action

Usage

var createAction = require('hudkit-action');

var myAction = createAction(function() {
    console.log("HELLO WORLD");
});

myAction(); // => "HELLO WORLD"
myAction.disable();
myAction(); // (nothing)

API

action(callback, [opts])

Create a new action with the given callback.

Option keys:

  • title: action title, default: ''
  • enabled: action enabled, default: true

action.getTitle()

Returns the action's title.

action.setTitle(title)

Set's the action title.

action.isEnabled()

Returns true if action is enabled, false otherwise.

action.toggleEnabled()

Toggle action enabled.

action.disable()

Disable action.

action.enable()

Enable action.

action.setEnabled(isEnabled)

Set action enabled explicitly.

action.onchange

Signalkit signal that will be emitted when the action's state is changed.

Something went wrong with that request. Please try again.