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

@rematch/loading

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rematch/loading

Loading indicator plugin for Rematch

  • 0.1.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.3K
increased by0.33%
Maintainers
2
Weekly downloads
 
Created
Source

Rematch Loading

Adds automated loading indicators for effects to Rematch. Inspired by dva-loading.

Example

See an example below using a loading indicator within a button.

import React from 'react'
import { dispatch } from '@rematch/core'
import AwesomeLoadingButton from './components/KindaCoolLoadingButton'

const LoginButton = (props) => (
  <AwesomeLoadingButton onClick={props.submit} loading={props.loading}>
    Login
  </AwesomeLoadingButton>
)

const mapToProps = state => ({
  submit: () => dispatch.login.submit(),
  loading: state.loading.models.login,
  submitting: state.loading.effects.login.submit,
})

export default connect(mapState)(App)

In the above case:

  • 'loading' is triggered whenever any effect on the login model is running
  • 'submitting' is triggered while login.submit is running

Demo

See a demo

Setup

Install @rematch/loading as a dependency.

npm install @rematch/loading

Configure loading.

import { init } from '@rematch/core'
import createLoadingPlugin from '@rematch/loading'

// see options API below
const options = {}

const loading = createLoadingPlugin(options)

init({
  plugins: [loading]
})

Options

name

The loading reducer defaults to the name of "loading".

If you would like to change this, use the name option.

const loading = createLoadingPlugin({ name: 'load' })

In which case, loading can be accessed from state.load.global.

Keywords

FAQs

Package last updated on 24 Nov 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