npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

redux-promising-modals

v2.1.2

Published

A middleware, reducer and actions for manipulating modal windows

Readme

Synopsis

A middleware, reducer and actions for manipulating modal windows.
The library provides only these things. If you want to see modal window, you could use react-modal.
See working example at gh-pages.

Code Example

Adding modals' reducer:

import { combineReducers } from 'redux';
import { modalsReducer } from 'redux-promising-modals';

export default combineReducers({
    /* your's reducers */
    modals: modalsReducer
});

Creating a store:

import { createStore, applyMiddleware } from 'redux';
import { modalsMiddleware } from 'redux-promising-modals';
import yourReducer from 'yourReducerDirectory';

const store = createStore(yourReducer, applyMiddleware(modalsMiddleware));

Show single modal:

import { pushModalWindow } from 'redux-promising-modals';
// ToDo: bind pushModalWindow to dispatch

pushModalWindow('EDIT_FILE_DIALOG', {fileName: 'my_file.txt'})
  .then(result => { /* do something with the result */ });

Show series of modals

import { pushModalWindow } from 'redux-promising-modals';
// ToDo: bind pushModalWindow to dispatch

const promisesArray = pushModalWindow(
    ['EDIT_FILE_DIALOG', 'REMOVE_FILE_DIALOG'],
    [{fileName: 'my_file.txt'}, {fileName: 'old_file.txt', _createdOn: 1480021259507}]
);

Promise.all(promisesArray).then(() => { /* all promises are resolved (each window was closed) */ });

Close current modal and return result

import { popModalWindow } from 'redux-promising-modals';
/* ToDo: bind popModalWindow to dispatch */

popModalWindow({newFileName: 'your_file.txt'});

Motivation

For example:
You need to show a modal window to a user. The user manipulates with the content of the window and then closes it. You want to see the result of these manipulation.

Installation

npm i --save redux-promising-modals

API Reference

Actions' types

PUSH_MODAL_WINDOW,
INSERT_MODAL_WINDOW,
POP_MODAL_WINDOW,
CLEAR_MODAL_WINDOWS

You can import theses types from library and handle them separately.

Middleware

modalsMiddleware

If the type of action passing through it is PUSH_MODAL_WINDOW or INSERT_MODAL_WINDOW you can expect that a Promise will be returned.
If the type is SHIFT_MODAL_WINDOW or POP_MODAL_WINDOW the Promise will be resolved and the result will be granted.
CLEAR_MODAL_WINDOWS resolves all Promises.

Actions

pushModalWindow(modalTypes, modalProps) - adds modal of type modalType (expects a String type but this is not necessary) with modalProps (could be anything) in the end of modals array. modalTypes and modalProps can be either an array or a single element (see Code Example).
insertModalWindow(modalTypes, modalProps) - adds a modal in the beginning of modals array.
popModalWindow(values) - removes the last window from modals array.
shiftModalWindow(values) - remove the first (current) window from modals array.
clearModalWindows() - clears modals array.
nextModalWindow() - replaces current window by the next.
prevModalWindow() - replaces current window by the previous one.

Reducer

modalsReducer - a reducer for modals (keep modals types and props in an array).

License

MIT