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

redux-script-loader

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-script-loader

Redux middleware to load scripts dynamically onto the document

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

redux-script-loader

Contents

  1. Usage
  2. Installation
  3. API
  4. RSL Actions

Usage

A simple example:

import { RSL_LOAD } from 'redux-script-loader';

dispatch({
  type: RSL_LOAD,
  payload: 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js',
  success: 'LOAD_SUCCESS',
  fail: 'LOAD_FAIL',
});

Installation

To install from npm:

$ npm install --save redux-script-loader

Then to configure with your redux store:

import { createStore, applyMiddleware } from 'redux';
import { loaderMiddleware } from 'redux-script-loader';
import reducer from './reducers';

const store = createStore(reducer, applyMiddleware(loaderMiddleware(document)));

API

RSL_LOAD :: Symbol

A symbol indicating that the action should be handled by the redux-script-loader middleware.

loaderMiddleware :: Function

Returns a redux-compatible middleware. Must be initialised with the document object.

RSL Actions

action.type :: Symbol

Must be RSL_LOAD imported from the redux-script-loader package.

action.payload :: String

The URL from which to load the script. Will be used as the src attribute of the script tag.

action.append :: String | FSA

Action to dispatch when appending the script tag to the document. Can either be a string, or a Flux standard action.

action.success :: String | FSA

Action to dispatch when the appended script tag finishes loading. Equivalent to the load event on the script element.

action.fail :: String | FSA

Action to dispatch when the appended script tag fails to load. Equivalent to the error event on the script element.

Keywords

FAQs

Package last updated on 14 Sep 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