Showing posts with label notify. Show all posts
Showing posts with label notify. Show all posts


October 25, 2017
Web Notifications Powered by RxJS for Angular


Install @ngrx/notify from npm:
 npm install @ngrx/notify --save  
Setup the providers, optionally providing global notification options:
 import { NOTIFY_PROVIDERS, NOTIFY_GLOBAL_OPTIONS } from '@ngrx/notify';  
 bootstrap(App, [  
  { provide: NOTIFY_GLOBAL_OPTIONS, multi: true, useValue: { /* global options here */ } }  


Requesting Notification Permission

Before creating notifications, you must resolve the app's notification permission:
 class AppComponent {  
  constructor(notify: Notify) {  
   notify.requestPermission().subscribe(permission => {  
    if (permission) {  
     // continue  

Creating a Notification

To create a notification observable, call the open() method with a title and optional config. The notification will be opened when you subscribe to the observable and will close after you unsubscribe from it. The observable will emit the instance of the notification every time it is clicked on:'Hello world!', options)  
  // Automatically close the notification after 5 seconds  
  // Close the notification after it has been clicked once  
  .subscribe(notification => {  
See the documentation on MDN for available options.

Note: Special thanks to ngrx

Disclaimer: The blog is created to share angular directives information to geek, curious Angular Developers.