Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ngxs-labs/actions-executing
https://github.com/ngxs-labs/actions-executing
ngxs stage-2
Last synced: about 5 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/ngxs-labs/actions-executing
- Owner: ngxs-labs
- License: mit
- Created: 2019-10-11T12:42:02.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-22T00:23:47.000Z (20 days ago)
- Last Synced: 2024-11-06T08:18:59.541Z (4 days ago)
- Topics: ngxs, stage-2
- Language: TypeScript
- Homepage:
- Size: 2.61 MB
- Stars: 27
- Watchers: 5
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
![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](https://coveralls.io/repos/github/ngxs-labs/actions-executing/badge.svg?branch=master)](https://coveralls.io/github/ngxs-labs/actions-executing?branch=master)
---
# NGXS Actions Executing
## Demo
[Link](https://ngxs-labs-actions-executing.netlify.app/)
## 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-ivy | 0.x |
| ivy | 1.x (compiled in partial mode) |## Quick start
Install the plugin:
- npm
```console
npm install --save @ngxs-labs/actions-executing
```- yarn
```console
yarn add @ngxs-labs/actions-executing
```Next, include it in you `app.module.ts`
```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()`
```ts
//...
import { actionsExecuting, ActionsExecuting } from '@ngxs-labs/actions-executing';//...
export class SingleComponent {
@Select(actionsExecuting([MyAction])) myActionIsExecuting$: Observable;
}
```then you can disable a button or display a loading indicator very easily
```html
My Action
Loading...
```## More examples
`actionsExecuting` selector returns the type `ActionsExecuting`
```ts
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.```ts
@Select(actionsExecuting([Action1, Action2])) multipleActions$: Observable;
```