Example #1
0
 ChangeFilter.prototype.has = function (key) {
     if (this._changes[key]) {
         var /** @type {?} */ value = this._changes[key].currentValue;
         return Observable$1.of(value);
     }
     return Observable$1.empty();
 };
Example #2
0
     .mergeMap(function (_a) {
     var route = _a.route, routeParams = _a.routeParams, queryParams = _a.queryParams, isTerminal = _a.isTerminal;
     if (isTerminal) {
         var match_1 = {
             routes: [route],
             routeParams: routeParams,
             queryParams: queryParams,
             locationChange: locationChange
         };
         return Observable_1.Observable.of(route)
             .mergeMap(function (route) { return _this._loadIndex(route); })
             .map(function (index) {
             if (!!index) {
                 match_1.routes.push(index);
             }
             return match_1;
         });
     }
     return Observable_1.Observable.of(route)
         .mergeMap(function (route) { return _this._loadChildRoutes(route); })
         .mergeMap(function (childRoutes) { return _this._matchRoutes(queryParams, locationChange, pathname, remainingPathname, childRoutes, paramNames, paramValues); })
         .map(function (match) {
         if (!!match) {
             match.routes.unshift(route);
             return match;
         }
         return null;
     });
 });
Example #3
0
 ChangeFilter.prototype.notEmpty = function (key) {
     if (this._changes[key]) {
         var /** @type {?} */ value = this._changes[key].currentValue;
         if (value !== undefined && value !== null) {
             return Observable$1.of(value);
         }
     }
     return Observable$1.empty();
 };
Example #4
0
    .concatMap((tree) => {
    if (!error) {
        // Output the logging queue.
        loggingQueue.forEach(log => logger.info(log));
    }
    if (dryRun || error) {
        return Observable_1.Observable.of(tree);
    }
    return fsSink.commit(tree).ignoreElements().concat(Observable_1.Observable.of(tree));
})
 function AppComponent(store) {
     this.click$ = new Subject_1.Subject()
         .map(function (value) { return ({ type: reducers_1.HOUR, payload: parseInt(value) }); });
     this.seconds$ = Observable_1.Observable
         .interval(1000)
         .mapTo({ type: reducers_1.SECOND, payload: 3 });
     this.time = store.select('clock');
     this.people = store.select('people');
     Observable_1.Observable.merge(this.click$, this.seconds$)
         .subscribe(store.dispatch.bind(store)); //Note this
 }
Example #6
0
  requestMediaKeySystemAccess = function(keyType, keySystemConfigurations) {
    if (!isTypeSupported(keyType)) {
      return Observable.throw();
    }

    for (let i = 0; i < keySystemConfigurations.length; i++) {
      const keySystemConfiguration = keySystemConfigurations[i];
      const {
        videoCapabilities,
        audioCapabilities,
        initDataTypes,
        sessionTypes,
        distinctiveIdentifier,
        persistentState,
      } = keySystemConfiguration;

      let supported = true;
      supported = supported && (
        !initDataTypes ||
        !!find(initDataTypes, (initDataType) => initDataType === "cenc")
      );
      supported = supported && (
        !sessionTypes ||
         sessionTypes.filter((sessionType) => sessionType === "temporary").length === sessionTypes.length
      );
      supported = supported && (distinctiveIdentifier !== "required");
      supported = supported && (persistentState !== "required");

      if (supported) {
        const keySystemConfigurationResponse = {
          videoCapabilities,
          audioCapabilities,
          initDataTypes: ["cenc"],
          distinctiveIdentifier: "not-allowed",
          persistentState: "not-allowed",
          sessionTypes: ["temporary"],
        };

        return Observable.of(
          new KeySystemAccess(keyType,
                              new MockMediaKeys(keyType),
                              keySystemConfigurationResponse)
        );
      }
    }

    return Observable.throw();
  };
Example #7
0
function canPlay(videoElement) {
  if (videoElement.readyState >= HAVE_ENOUGH_DATA) {
    return Observable.of(null);
  } else {
    return on(videoElement, "canplay").take(1);
  }
}
Example #8
0
function canSeek(videoElement) {
  if (videoElement.readyState >= HAVE_METADATA) {
    return Observable.of(null);
  } else {
    return loadedMetadataEvent(videoElement).take(1);
  }
}
Example #9
0
function sourceOpen(mediaSource) {
  if (mediaSource.readyState == "open") {
    return Observable.of(null);
  } else {
    return sourceOpenEvent(mediaSource).take(1);
  }
}
Example #10
0
 Popup.prototype.pollPopup = function () {
     var _this = this;
     return rxjs_Observable.Observable
         .interval(50)
         .concatMap(function () {
         if (!_this.popupWindow || _this.popupWindow.closed) {
             return ['Popup Window Closed'];
         }
         var documentOrigin = document.location.host;
         var popupWindowOrigin = '';
         try {
             popupWindowOrigin = _this.popupWindow.location.host;
         }
         catch (error) {
         }
         if (popupWindowOrigin === documentOrigin && (_this.popupWindow.location.search || _this.popupWindow.location.hash)) {
             var queryParams = _this.popupWindow.location.search.substring(1).replace(/\/$/, '');
             var hashParams = _this.popupWindow.location.hash.substring(1).replace(/[\/$]/, '');
             var hash = Popup.parseQueryString(hashParams);
             var qs = Popup.parseQueryString(queryParams);
             _this.popupWindow.close();
             extend(qs, hash);
             if (qs.error) {
                 throw qs.error;
             }
             else {
                 return [qs];
             }
         }
         return [];
     })
         .take(1)
         .takeWhile(function (response) { return response !== 'Popup Window Closed'; });
 };
Example #11
0
 Shared.prototype.logout = function () {
     this.storage.remove(this.tokenName);
     return rxjs_Observable.Observable.create(function (observer) {
         observer.next();
         observer.complete();
     });
 };
exports.ConnectionSubject = function(io){
  var packetDecoder = new Decoder();
  var observable = Observable.create(function(subscriber){
      io.on('connection', function(socket){
        socket.client.conn.on('packet', function(packet){
          if(packet.type === 'message'){
            packetDecoder.add(packet.data);
          }
        });
        packetDecoder.on('decoded', function(packet){
          subscriber.next(packet);
        })
      })

      return function(){
        console.log("client disconnected");
      }
  })

  var observer = Subscriber.create(function(x){
    console.log('ConnectionSubjectSubscriber::next', x);
  });

  return Subject.create(observer, observable)
}
 LeagueRankingsService.prototype.handleError = function (error) {
     // In a real world app, we might use a remote logging infrastructure
     // We'd also dig deeper into the error to get a better message
     var errMsg = error.message || error.statusText || 'Server error';
     console.error(errMsg); // log to console instead
     return Observable_1.Observable.throw(errMsg);
 };
 createEventObservable(eventName, marker) {
     return Observable.create((observer) => {
         this._markers.get(marker).then((m) => {
             m.addListener(eventName, (e) => this._zone.run(() => observer.next(e)));
         });
     });
 }
Example #15
0
File: webdav.js Project: SqrTT/Bart
    dirList (filePath = '.', root = this.config.root) {
        const uriPath = path.relative(root, filePath);

        return Observable.create(observer => {
            const req = request(Object.assign(this.getOptions(), {
                uri: '/' + uriPath,
                headers: {
                    Depth: 1
                },
                method: 'PROPFIND'
            }), (err, res, body) => {
                if (err) {
                    observer.error(err);
                } else if (res.statusCode >= 400) {
                    observer.error(new Error(res.statusMessage));
                } else {
                    observer.next(body);
                }

                observer.complete();
            });

            return () => req.destroy();
        });
    }
Example #16
0
  constructor(name) {
    if (!name) {
      throw Error('Command need a name');
    }
    this.rl = readline.createInterface(process.stdin, process.stdout)
    this.name = name;
    let self = this;

    this.commandDispatcher = Observable.create((observer) => {
      if (process.argv.lenght <= 2) {
        observer.complete();
      }
      let args = this._copy(process.argv);
      args.splice(0, 2);
      observer.next(args);
      observer.complete();
    })
      .catch((e) => {
        throw new Error(e);
      })
      .filter((data) => {
        //console.log(data[2] === this.name, data[2], this.name);
        return data[0] === this.name;
      });
  }
Example #17
0
File: webdav.js Project: SqrTT/Bart
    delete(filePath, optionalRoot) {
        const uriPath = path.relative(optionalRoot || this.config.root, filePath);

        return Observable.create(observer => {
            this.log('delete', uriPath);
            const req = request(Object.assign(this.getOptions(), {
                uri: '/' + uriPath,
                method: 'DELETE'
            }), (err, res, body) => {
                this.log('delete-response', uriPath, body);
                if (err) {
                    observer.error(err);
                } else if (res.statusCode >= 400 && res.statusCode !== 404) {
                    // it's ok to ignore 404 error if the file is not found
                    observer.error(new Error(res.statusMessage));
                } else {
                    observer.next(body);
                }

                observer.complete();
            });

            return () => req.destroy();
        });
    }
Example #18
0
 Popup.prototype.eventListener = function (redirectUri) {
     var _this = this;
     return rxjs_Observable.Observable
         .fromEvent(this.popupWindow, 'loadstart')
         .concatMap(function (event) {
         if (!_this.popupWindow || _this.popupWindow.closed) {
             return ['Popup Window Closed'];
         }
         if (event.url.indexOf(redirectUri) !== 0) {
             return [];
         }
         var parser = document.createElement('a');
         parser.href = event.url;
         if (parser.search || parser.hash) {
             var queryParams = parser.search.substring(1).replace(/\/$/, '');
             var hashParams = parser.hash.substring(1).replace(/\/$/, '');
             var hash = Popup.parseQueryString(hashParams);
             var qs = Popup.parseQueryString(queryParams);
             extend(qs, hash);
             _this.popupWindow.close();
             if (qs.error) {
                 throw qs.error;
             }
             else {
                 return [qs];
             }
         }
         return [];
     })
         .take(1)
         .takeWhile(function (response) { return response !== 'Popup Window Closed'; });
 };
 subscribeToMapEvent(eventName) {
     return Observable.create((observer) => {
         this._map.then((m) => {
             m.addListener(eventName, (arg) => { this._zone.run(() => observer.next(arg)); });
         });
     });
 }
Example #20
0
 return observable.catch(function (err, source) {
     if (err.status == 401 && err.url.indexOf('/login') == -1) {
         if (err.url.indexOf('/refreshToken') > -1) {
             // if the token refresh doesn't work, the user account has become invalid
             _this.reset();
             _this.router.navigate(['/welcome']);
         }
         else {
             // redirect the user to the unauthorized page?
             _this.router.navigate(['/app/unauthorized']);
         }
         return Observable_1.Observable.empty();
     }
     else {
         return Observable_1.Observable.throw(err);
     }
 });
Example #21
0
 MarkerManager.prototype.createEventObservable = function (eventName, marker) {
     var _this = this;
     return Observable_1.Observable.create(function (observer) {
         _this._markers.get(marker).then(function (m) {
             m.addListener(eventName, function (e) { return _this._zone.run(function () { return observer.next(e); }); });
         });
     });
 };
Example #22
0
  PrimitiveTerm.prototype.watch = function watch() {
    for (var _len = arguments.length, watchArgs = Array(_len), _key = 0; _key < _len; _key++) {
      watchArgs[_key] = arguments[_key];
    }

    checkWatchArgs(watchArgs);
    return _Observable.Observable.of(this._value);
  };
Example #23
0
  AggregateTerm.prototype.fetch = function fetch() {
    if (this._value.length === 0) {
      return _Observable.Observable.of({});
    }

    var qs = this._query('fetch');
    return _Observable.Observable.forkJoin.apply(_Observable.Observable, qs.concat([this._reducer]));
  };
Example #24
0
  ObservableTerm.prototype.watch = function watch() {
    for (var _len2 = arguments.length, watchArgs = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
      watchArgs[_key2] = arguments[_key2];
    }

    checkWatchArgs(watchArgs);
    return _Observable.Observable.from(this._value);
  };
 MdIconRegistry.prototype.getSvgIconFromUrl = function (url) {
     var _this = this;
     if (this._cachedIconsByUrl.has(url)) {
         return Observable_1.Observable.of(cloneSvg(this._cachedIconsByUrl.get(url)));
     }
     return this._loadSvgIconFromConfig(new SvgIconConfig(url))
         .do(function (svg) { return _this._cachedIconsByUrl.set(url, svg); })
         .map(function (svg) { return cloneSvg(svg); });
 };
Example #26
0
 .switchMap((action) => {
   const user = createUserFirebase(action.payload.firebaseUser);
   if (user) {
     return createInfoConnected$(user).takeUntil(
       action$.filter((action: Action) => action.type === 'APP_STOP'),
     );
   }
   return Observable.of();
 });
Example #27
0
 BaseService.prototype.handleErrorMessage = function (error) {
     console.log(error.status + ": " + error.message);
     var message = "Что-то пошло не так";
     var a = error._body;
     if (a != null) {
         message = error._body;
     }
     return Observable_1.Observable.throw(message);
 };
Example #28
0
 RouteTraverser.prototype._matchRouteDeep = function (route, queryParams, locationChange, pathname, remainingPathname, paramNames, paramValues) {
     var _this = this;
     var pattern = route.path || '';
     return Observable_1.Observable.of(route)
         .filter(function () { return remainingPathname !== null; })
         .do(function () {
         var matched = match_pattern_1.matchPattern(pattern, remainingPathname);
         remainingPathname = matched.remainingPathname;
         paramNames = paramNames.concat(matched.paramNames);
         paramValues = paramValues.concat(matched.paramValues);
     })
         .filter(function () { return remainingPathname !== null; })
         .map(function () {
         return {
             route: route,
             queryParams: queryParams,
             locationChange: locationChange,
             routeParams: match_pattern_1.makeParams(paramNames, paramValues),
             isTerminal: remainingPathname === '' && !!route.path
         };
     })
         .let(hooks_1.composeHooks(this._hooks))
         .filter(function (_a) {
         var route = _a.route;
         return !!route;
     })
         .mergeMap(function (_a) {
         var route = _a.route, routeParams = _a.routeParams, queryParams = _a.queryParams, isTerminal = _a.isTerminal;
         if (isTerminal) {
             var match_1 = {
                 routes: [route],
                 routeParams: routeParams,
                 queryParams: queryParams,
                 locationChange: locationChange
             };
             return Observable_1.Observable.of(route)
                 .mergeMap(function (route) { return _this._loadIndex(route); })
                 .map(function (index) {
                 if (!!index) {
                     match_1.routes.push(index);
                 }
                 return match_1;
             });
         }
         return Observable_1.Observable.of(route)
             .mergeMap(function (route) { return _this._loadChildRoutes(route); })
             .mergeMap(function (childRoutes) { return _this._matchRoutes(queryParams, locationChange, pathname, remainingPathname, childRoutes, paramNames, paramValues); })
             .map(function (match) {
             if (!!match) {
                 match.routes.unshift(route);
                 return match;
             }
             return null;
         });
     });
 };
Example #29
0
function EmptyBuffer(bufferType) {
  return Observable.of({
    type: "buffer",
    value: {
      bufferType,
      adaptation: null,
      representation: null,
    },
  });
}
Example #30
0
 .mergeMap((action) => {
   const { email, ...user } = action.payload.user;
   const promise = firebase.update({
     [`users/${user.id}`]: user,
     [`users-emails/${user.id}`]: { email },
   });
   return Observable.from(promise)
     .map(saveUserDone)
     .catch(error => Observable.of(appError(error)));
 });