Socket
Socket
Sign inDemoInstall

@orchestrator/ngx-until-destroyed

Package Overview
Dependencies
2
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @orchestrator/ngx-until-destroyed

RxJS operator that unsubscribes from observable on Angular component destruction


Version published
Weekly downloads
67
decreased by-21.18%
Maintainers
3
Install size
24.8 kB
Created
Weekly downloads
 

Changelog

Source

1.1.1 (2019-01-17)

Bug Fixes

  • package: paths to bundled files (fe0ea97)

Bug Fixes

  • decorator: do not override props with same name (d3e7043)

Features

  • lib: reorganize code structure and package gen (52fc370)

Readme

Source

🤓 Angular - Unsubscribe For Pros 💪

Build Status Coverage Npm Npm Downloads Licence semantic-release

Declarative way to unsubscribe from observables when the component destroyed

Installation

$ npm install @orchestrator/ngx-until-destroyed --save

Usage

import { untilDestroyed } from '@orchestrator/ngx-until-destroyed';

@Component({
  selector: 'app-inbox',
  templateUrl: './inbox.component.html',
})
export class InboxComponent implements OnInit, OnDestroy {
  ngOnInit() {
    interval(1000)
      .pipe(untilDestroyed(this))
      .subscribe(val => console.log(val));
  }

  // This method must be present, even if empty.
  ngOnDestroy() {
    // To protect you, we'll throw an error if it doesn't exist.
  }
}

Use with decorator

import { WithUntilDestroyed } from '@orchestrator/ngx-until-destroyed';

@Component({...})
class MyComponent implements OnDestroy {
  @WithUntilDestroyed()
  stream$ = interval(1000); // You can safely subscribe to this everywhere

  // This method must be present, even if empty
  ngOnDestroy() {}
}

Use with any class

import { untilDestroyed } from '@orchestrator/ngx-until-destroyed';

export class Widget {
  constructor() {
    interval(1000)
      .pipe(untilDestroyed(this, 'destroy'))
      .subscribe(console.log);
  }

  // The name needs to be the same as the decorator parameter
  destroy() {}
}

Keywords

FAQs

Last updated on 17 Jan 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc