Saka7 / ng-network-status

Angular module for tracking "network status change" events
https://www.npmjs.com/package/ng-network-status
MIT License
12 stars 2 forks source link

Update to angular@6.0 and rxjs@6.1 #1

Open Albejr opened 6 years ago

Albejr commented 6 years ago

Summary

I'm submitting a:

Description

Necessary to compatibility of import paths to new structure. image

Demo

Lib versions:

Angular CLI: 6.0.0
Node: 8.11.1
OS: win32 x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, material, platform-browser
... platform-browser-dynamic, platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.6.0
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.0
@angular/cdk                      5.2.5
@angular/http                     5.2.10
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.0
@schematics/update                0.6.0
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0
marie-dk commented 6 years ago

Same trouble here, but I managed to get it working with rxjs 6.2.2. I don't know much about github, so I'll leave my changes here.... Maybe it will be helpful to someone who passes by this issue... And if we are in any luck, maybe the maintainer will fix it ;-)

In src/services/network-status.service.ts:

- import { Observable } from 'rxjs/Rx';
+ import { Observable, interval } from 'rxjs';
+ import { timeInterval,map} from 'rxjs/operators';
- private registerNetworkHealthChecker(interval: number, options: Options) {
-    this.networkStatus = Observable
-      .interval(interval)
-      .timeInterval()
-      .map(() => {
-        if(window.navigator.onLine) {
-          if(options.grayscale.enabled) {
-            this.removeGrayScaleEffect(options.grayscale.animationDuration);
-          }
-          return true;
-        } else {
-          if(options.grayscale.enabled) {
-            this.addGrayScaleEffect(options.grayscale.percentage,
-              options.grayscale.animationDuration);
-          }
-          return false;
-        };
-      });
-  }

+  private registerNetworkHealthChecker(int: number, options: Options)  {
+
+    const interval$ = interval(int);
+        
+    this.networkStatus = interval$.pipe(
+      timeInterval(),
+      map(() => {
+        if (window.navigator.onLine) {
+          if (options.grayscale.enabled) {
+            _this.removeGrayScaleEffect(options.grayscale.animationDuration);
+          }
+          return true;
+        }  else {
+          if (options.grayscale.enabled) {
+            _this.addGrayScaleEffect(options.grayscale.percentage, options.grayscale.animationDuration);
+          }
+          return false;
+        }
+      })
+    )
+  }