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 🙏

© 2024 – Pkg Stats / Ryan Hefner

tbc-common-loader

v0.1.5

Published

Common Loaders for all Trinidad Benham React apps

Downloads

3

Readme

TBC Common React App Loaders

Common Loaders for all Trinidad Benham React apps

Install

npm install --save tbc-common-loader

Redux Store

In Actions.js file:

import * as loadingActions from "tbc-common-loader/dist/Redux/LoadingActions";

Then add "loadingActions" to actions object.

In configureStore.js file:

import loadingState from "tbc-common-loader/dist/Redux/loadingStateReducer";

Then add "loadingState" to combineReducers object.

In action files that should dispatch "setLoading" or "setAltLoading":

import { setLoading, setAltLoading } from "tbc-common-loader/dist/Redux/LoadingActions";

Loading Spinner Component:

In component toward top of hierarchy with access to state ("loadingState", specifically):

import Loading from "tbc-common-loader/dist/Component/Loading";

<Loading loadingState={loadingState} />

Component is a modal, so will sit on top of any children components.

loadingState here refers to the actual Redux store state (provided as part of the module)

Loading Progress Bar Component:

In component toward top of hierarchy with access to state ("loadingState", specifically):

import AltLoader from "tbc-common-loader/dist/Component/AltLoader";

<AltLoader loadingState={loadingState} />

Component is a progress bar, so should be placed where it will display above or below the UI.

loadingState here refers to the actual Redux store state (provided as part of the module)

Activating/deactivating Loader

To enable loading, dispatch setLoading({message}) or setAltLoading({message}) where {message} is the loading message you wish to display. If no message is required, use Boolean true instead.

To disable loading, dispatch setLoading(false) or setAltLoading(false).

NOTE: Loading state is incremental, meaning you can call setLoading/setAltLoading multiple times with multiple messages; the latest message will be displayed, and then when setLoading/setAltLoading is set to false, the last message will removed.

Example: You are loading two API calls back-to-back. In order to prevent flickering with the loading modal, the calls should be made as follows:

const API_one = () => { dispatch(setLoading("API Call One")); ... .then(() => { // when API call is done dispatch(setLoading(false)); }) };

const API_two = () => { dispatch(setLoading("API Call Two")); ... .then(() => { // when API call is done dispatch(setLoading(false)); }) };

When these two calls are made back to back, the loading message will appear with "API Call One" first, replaced by "API Call Two". Then, when the first API call is complete, the "...Two" message will be removed, revealing "API Call One". When the second call is complete, then the "...One" message will be removed, and without any messages, the loading modal will vanish.

PropTypes

import * as loadingTypes from "tbc-common-loader/dist/Types/types";

Component.propTypes = {
  loadingState: loadingTypes.loadingState.types
};

Component.defaultProps = {
  loadingState: loadingTypes.loadingState.defaults
};

ActionTypes

For some components (testing, in particular), you may need to import ActionTypes from the Loading module. Use the following:

import { SET_LOADING, SET_ALT_LOADING } from "tbc-common-loader/dist/Redux/ActionTypes";

Required NPM Packages

npm install --save bootstrap reactstrap @material-ui/core lodash

Testing

For any unit test file that deep renders ("mounts") this imported component, add the following:

jest.mock("tbc-common-loader/dist/Component/Loading", () => "div"); jest.mock("tbc-common-loader/dist/Component/AltLoader", () => "div");