Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dojo-actions

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dojo-actions

A command library for Dojo 2 Applications

  • 2.0.0-alpha.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

dojo-actions

Build Status codecov.io npm version

A command like library for Dojo 2 Applications.

NOTE At this stage, this is a functional prototype for a proposal that is under discussion. This is not yet intended for production use. Consider it pre-alpha and is intended to allow people to assess the API. Use at your own risk and the final API may or may not look anything like this

Features

Actions embody the concept of doing something that can be express behaviour without having to re-implement the behaviour in various locations of an application. In the concept of a Dojo 2 application, Widgets call Actions which mutate state in Stores which change the State of Widgets.

Creation

To create a new action, simply use the Action factory:

import createAction from 'dojo-actions/createAction';

const action = createAction({
    do() {
        /* do something */
    }
});

action
    .do()
    .then((result) => {
        /* do something with the result */
    });

You must specify a do() method when using the Action factory. The Action will wrap the .do() method, ensuring that no matter what the return, it will return a dojo-core/async/Task which is a Promise with the ability to cancel.

State

Each Action has a .state object which contains any sort of mutatable state. This is provided by the dojo-compose/mixin/createStateful mixin. When the .do() method is invoked, it is scoped so that this is the calling action, and therefore this.state can be used to read from the state.

Future

It is envisioned that some foundational "helper" actions will be added to this package to make it easy.

How do I use this package?

The easiest way to use this package is to install it via npm:

$ npm install dojo-actions

In addition, you can clone this repository and use the Grunt build scripts to manage the package.

Using under TypeScript or ES6 modules, you would generally want to just import the dojo-actions/createAction module:

import createAction from 'dojo-compose/createAction';

const action = createAction({
    do() { /* do something */ }
});

action.do();

How do I contribute?

We appreciate your interest! Please see the Dojo 2 Meta Repository for the Contributing Guidelines and Style Guide.

Testing

Test cases MUST be written using Intern using the Object test interface and Assert assertion interface.

90% branch coverage MUST be provided for all code submitted to this repository, as reported by istanbul’s combined coverage results for all supported platforms.

To test locally in node run:

grunt test

To test against browsers with a local selenium server run:

grunt test:local

To test against BrowserStack or Sauce Labs run:

grunt test:browserstack

or

grunt test:saucelabs

Licensing information

TODO: If third-party code was used to write this library, make a list of project names and licenses here

© 2004–2015 Dojo Foundation & contributors. New BSD license.

FAQs

Package last updated on 23 Aug 2016

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