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

@ngxs-labs/actions-executing

Package Overview
Dependencies
Maintainers
8
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ngxs-labs/actions-executing

![master](https://github.com/ngxs-labs/actions-executing/workflows/main/badge.svg?branch=master) [![npm version](https://badge.fury.io/js/%40ngxs-labs%2Factions-executing.svg)](https://badge.fury.io/js/%40ngxs-labs%2Factions-executing) [![Coverage Status]

  • 18.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
8
Created
Source

master npm version Coverage Status


NGXS Actions Executing

Demo

Link

Description

This plugin allows you to easily know if an action is being executed and control UI elements or control flow of your code to execute. The most common scenarios for using this plugin are to display loading spinner or disable a button while an action is executing.

Compatibility

Angular@ngxs-labs/actions-executing
non-ivy0.x
ivy1.x (compiled in partial mode)

Quick start

Install the plugin:

  • npm
npm install --save @ngxs-labs/actions-executing
  • yarn
yarn add @ngxs-labs/actions-executing

Next, include it in you app.module.ts

//...
import { NgxsModule } from '@ngxs/store';
import { NgxsActionsExecutingModule } from '@ngxs-labs/actions-executing';

@NgModule({
    //...
    imports: [
        //...
        NgxsModule.forRoot([
            //... your states
        ]),
        NgxsActionsExecutingModule.forRoot()
    ]
    //...
})
export class AppModule {}

To use it on your components you just need to include the following @Select()

//...
import { actionsExecuting, ActionsExecuting } from '@ngxs-labs/actions-executing';

//...
export class SingleComponent {
    @Select(actionsExecuting([MyAction])) myActionIsExecuting$: Observable<ActionsExecuting>;
}

then you can disable a button or display a loading indicator very easily

<button [disabled]="myActionIsExecuting$ | async" (click)="doSomething()">
    My Action
</button>

<span *ngIf="myActionIsExecuting$ | async">
    Loading...
</span>

More examples

actionsExecuting selector returns the type ActionsExecuting

type ActionsExecuting = { [action: string]: number } | null;

This allows you to know which actions and how many of them are being executed at any given time.

You can also pass multiple actions to the selector and this way you'll receive updates when any of those actions are executing.

@Select(actionsExecuting([Action1, Action2])) multipleActions$: Observable<ActionsExecuting>;

FAQs

Package last updated on 02 Jul 2024

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