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

flux-actions

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flux-actions

Basic class that wrap flux actions.

  • 0.1.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Flux Actions

Basic class that wrap flux actions.

How to use

import Actions from 'flux-actions';
import http from 'fetch-to-request';
import * as actionTypes from './actions-types/users';

class UsersActions extends Actions {
    show(userId) {
        this.dispatch(actionTypes.SHOW, { userId });
    }
    
    loadOne(userId) {
        this.dispatchPromise(http.get('/users/' + userId), {
            request: actionTypes.LOAD,
            request: actionTypes.LOAD_SUCCESS,
            request: actionTypes.LOAD_FAIL
        }, { userId });
    }
}

then when you need call the actions:

import {Dispatcher} from 'flux';
import UsersActions from './actions/UsersActions';

const dispatcher = new Dispatcher();
const usersActions = new UsersActions(dispatcher);

usersActions.show(1);
usersActions.loadOne(1);

Methods

constructor(dispatcher)

Please pass instance of flux Dispatcher here.

  • dispatcher - Dispatcher instance of flux Dispatcher

dispatch(type, payload)

Dispatch simple action.

  • type - string action type
  • payload - object a payload object

dispatchPromise(promise, types, payload)

Dispatch promise. When dispatchPromise() is called it put types.request action. When promise success it put types.success action. And when fail - types.fail action.

  • promise - Promise instance of Promise
  • types - { request, success, fail } object with list of types request/success/fail
  • payload - object a payload object

Keywords

FAQs

Package last updated on 17 May 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