Bläddra i källkod

Added more type control and fixes.

FAMBL 1 år sedan
förälder
incheckning
fc8c717731
2 ändrade filer med 9 tillägg och 3 borttagningar
  1. 7 3
      services/query.service.ts
  2. 2 0
      test/test4.ts

+ 7 - 3
services/query.service.ts

@@ -2,7 +2,7 @@ import { isObject, get } from 'lodash'
 import { Observable, Subject, interval, map, of } from 'rxjs'
 import { DataPrepService } from './dataprep.service'
 import _ = require("lodash")
-import { Conditions, DateRange, Storage } from '../types/interface'
+import { Conditions, DateRange, ObservableStorage, Storage, StorageLocation } from '../types/interface'
 export class SearchService {
 
     private dataPrepService: DataPrepService
@@ -25,12 +25,16 @@ export class SearchService {
         let filteredResult: Subject<any> = new Subject()
 
         if (storage.type == 'observable') {
-            let obsRef = storage.ref
+            // ObservableStorage
+            let currentStorage:ObservableStorage = storage;
+            let obsRef = currentStorage.ref
             obsRef.subscribe((element) => {
                 dataFromStorage.next(element)
             })
         } else {
-            this.dataPrepService.loadObsData(storage, dataFromStorage)
+            // StorageLocation
+            let currentStorage:StorageLocation = storage;
+            this.dataPrepService.loadObsData(currentStorage, dataFromStorage)
         }
 
         this.filterFromObs(dataFromStorage, filteredResult, ...conditions)

+ 2 - 0
test/test4.ts

@@ -101,6 +101,8 @@ let conditions8: Conditions[] = [
 
 
 let obsStorage : Subject<any> = new Subject()
+
+// The dataPrepService is only used to feed data to the subject observable and not required before .query 
 dataPrepService.loadObsData(mongoStorage, obsStorage)
 
 const testObs: ObservableStorage = {