All Projects → Storytel → react-redux-spinner

Storytel / react-redux-spinner

Licence: MIT license
An automatic spinner for react and redux

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to react-redux-spinner

Vue Simple Spinner
A simple, flexible spinner for Vue.js
Stars: ✭ 385 (+375.31%)
Mutual labels:  progress, spinner
Swiftloader
A simple and beautiful activity indicator written in Swift
Stars: ✭ 116 (+43.21%)
Mutual labels:  progress, spinner
Whirl
CSS loading animations with minimal effort!
Stars: ✭ 774 (+855.56%)
Mutual labels:  progress, spinner
React Circle
Renders a svg circle + progress, it just works 💘
Stars: ✭ 925 (+1041.98%)
Mutual labels:  progress, spinner
React Nprogress
⌛️ A React primitive for building slim progress bars.
Stars: ✭ 173 (+113.58%)
Mutual labels:  progress, spinner
react-awesome-loaders
🚀 High quality, super responsive and completely customisable Loading Animations to insert into your website with single line of code.
Stars: ✭ 146 (+80.25%)
Mutual labels:  progress, spinner
Fliplog
fluent logging with verbose insight, colors, tables, emoji, filtering, spinners, progress bars, timestamps, capturing, stack traces, tracking, presets, & more...
Stars: ✭ 41 (-49.38%)
Mutual labels:  progress, spinner
spinnies
Node.js module to create and manage multiple spinners in command-line interface programs
Stars: ✭ 111 (+37.04%)
Mutual labels:  progress, spinner
Apesuperhud
A simple way to display a HUD with a message or progress information in your application.
Stars: ✭ 156 (+92.59%)
Mutual labels:  progress, spinner
Vue Wait
Complex Loader and Progress Management for Vue/Vuex and Nuxt Applications
Stars: ✭ 1,869 (+2207.41%)
Mutual labels:  progress, spinner
Vue Loaders
Vue + loaders.css
Stars: ✭ 127 (+56.79%)
Mutual labels:  progress, spinner
Spinners React
Lightweight SVG/CSS spinners for React
Stars: ✭ 254 (+213.58%)
Mutual labels:  progress, spinner
Alive Progress
A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
Stars: ✭ 2,940 (+3529.63%)
Mutual labels:  progress, spinner
spinners-angular
Lightweight SVG/CSS spinners for Angular
Stars: ✭ 21 (-74.07%)
Mutual labels:  progress, spinner
RemainingCountIndicator
Remaining count indicator like a tweet screen of twitter.
Stars: ✭ 17 (-79.01%)
Mutual labels:  progress
loading
Laravel package to add loading indicator to pages while page is loading.
Stars: ✭ 38 (-53.09%)
Mutual labels:  spinner
AMProgressHUD
A gif progress HUD for iOS.
Stars: ✭ 18 (-77.78%)
Mutual labels:  progress
MatlabProgressBar
This MATLAB class provides a smart progress bar like tqdm in the command window and is optimized for progress information in simple iterations or large frameworks with full support of parallel parfor loops provided by the MATLAB Parallel Computing Toolbox.
Stars: ✭ 44 (-45.68%)
Mutual labels:  progress
redux-entities
Higher-order reducer for store entities received from normalizr and makes it easy to handle them.
Stars: ✭ 34 (-58.02%)
Mutual labels:  reducer
lsp spinner.nvim
neovim plugin to retrieve the name of the running LSP client(s) and display a spinner when there are wip job
Stars: ✭ 23 (-71.6%)
Mutual labels:  spinner

React Redux Spinner

A simple spinner for any "long" running tasks (such as fetching data off a server).

Demo of spinner functionality

DEMO: https://storytel.github.io/react-redux-spinner

Installation

npm install react-redux-spinner --save

Usage

Import the library.

import {
  Spinner, // The React component
  pendingTasksReducer, // The redux reducer
  pendingTask, // The action key for modifying loading state
  begin, // The action value if a "long" running task begun
  end, // The action value if a "long" running task ended
  endAll // The action value if all running tasks must end
} from 'react-redux-spinner';

Install the reducer to the store. Make sure it reduces the pendingTasks key. This is best done using combineReducers from redux.

import { createStore, combineReducers } from 'redux'
const reducer = combineReducers({
  pendingTasks: pendingTasksReducer
});

const store = createStore(reducer);

Put the Spinner component anywhere in your application.

import React from 'react';
const App extends React.Component {
  render() {
    return (<Spinner />)
  }
}

Start a long running task. This will typically be when you begin fetching data from a server.

This will increase the pending tasks counter by 1. The spinner will be shown when the pending tasks is greater than 0.

store.dispatch({
  type: 'ANY_OF_YOUR_ACTION_TYPES'
  [ pendingTask ]: begin // Make sure you embrace `pendingTask` in brackets [] to evaluate it
  // Any additional key/values may be included here
});

When your long running task is done.

store.dispatch({
  type: 'ANY_OF_YOUR_ACTION_TYPES_DONE'
  [ pendingTask ]: end // Bracket [] embrace, remember?
  // Any additional key/values may be included here
});

When you want to force the finish of all pending tasks (for example: with a global error).

store.dispatch({
  type: 'ANY_OF_YOUR_ACTION_TYPES_FINISH'
  [ pendingTask ]: endAll // Bracket [] embrace, remember?
  // Any additional key/values may be included here
});

CSS

By default, no styling is included. You can either roll your own. Feel free to use the default css as boilerplate.

If you're using webpack as your bundler, you could use style-loader and css-loader to include the default css.

In webpack.config.js:

  // ...
  module: {
    rules: {
      {
        test: /\.css$/,
        loader: 'style-loader!css-loader'
      }
    }
  }

and in your css files (the tilde ~ means "look in node_modules"):

@import '~react-redux-spinner/dist/react-redux-spinner.css';

Configurable reducer

Maybe you cannot have the pendingTask in the root of your actions. For instance, if you're trying to follow the Flux Standard Actions you're not allowed to have anything in the root except type, payload, error and meta. It would then be prudent to put pendingTask in meta. To get the reducer to look here instead you need to configure it to do so with configurablePendingTasksReducer.

import { configurablePendingTasksReducer } from 'react-redux-spinner';
import { createStore, combineReducers } from 'redux'
const pendingTasks = configurablePendingTasksReducer({ actionKeyPath: [ 'meta' ] });
const reducer = combineReducers({
  pendingTasks: pendingTasksReducer
});
const store = createStore(reducer);

and then dispatch actions:

store.dispatch({
  type: 'ANY_OF_YOUR_ACTION_TYPES'
  meta: {
    [ pendingTask ]: begin
  }
});

The actionKeyPath may be as deeply nested as required. For instance, if you'd like to have the keys in meta.async, you'd provide actionKeyPath: [ 'meta', 'async' ] and then dispatch actions with { meta: { async: { [ pendingTask ]: begin } } }

Pro-tips

  • Don't want to bloat your namespace with begin or end variables?
import rrs from 'react-redux-spinner';

dispatch({
  type: 'ACTION_TYPE',
  [ rrs.pendingTask ]: rrs.begin
});
import { pendingTasksReducer as pendingTasks } from 'react-redux-spinner';
const reducer = combineReducers({ pendingTasks });
  • Modify the appearance of the spinners (example modifies the color, but any css attributes can be set)
#nprogress .bar {
  background-color: #f4590a;
}

#nprogress .spinner-icon {
  border-top-color: #f4590a;
  border-left-color: #f4590a;
}

#nprogress .peg {
  box-shadow: 0 0 10px #f4590a, 0 0 5px #f4590a;
}
  render() {
    return (<Spinner config={{ trickleRate: 0.02 }} />)
  }
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].