this.notesDataService.getNotes().mergeMap(notes => Observable.from(notes)).subscribe(note => {
export function getLang(state$: Observable<IMultilingualState>) {
  return state$.select(state => state.lang);
}
 getErrorMessage: () => Observable.of('incorrect password'),
Example #4
0
 return (state$: Observable<AppState>) => state$
     .select(s => s.cart);
Example #5
0
    /**
     * Error handler
     * @param error
     * @returns { ErrorObservable }
     * @private
     */
    private _handleError (error: Response) {
        let errorMessage = error.text() || 'Server error';

        console.error(errorMessage);
        return Observable.throw(new Error(errorMessage));
    }
Example #6
0
 .catch((error: any) => {
     console.error(error);
     return Observable.throw(error.json().error || 'Server error');
 })
 // Uses Observable.forkJoin() to run multiple concurrent http.get() requests.
 // The entire operation will result in an error state if any single request fails.
 getBooksAndMovies() {
     return Observable.forkJoin(
     this.http.get('/api/books'),
     this.http.get('/api/movies')
     );
 }
 get: job => Observable.of()
Example #9
0
 return (state$: Observable<SearchState>) => state$
   .select(s => s.loading);
 save(entity) {
     return Observable.of(entity);
 }
 /*
  * Il metodo handleError serve a catturare un eventuale errore proveniente dal server.
  */
 private handleErrorLogout(error: any) {
     console.log("Error: " + JSON.stringify(error));
     let errMsg = "Non รจ possibile al momento effettuare il logout";
     console.error("ErrorMessage: " + errMsg);
     return Observable.throw(errMsg);
 }
Example #12
0
 private handleError (error: Response) {
     // in a real world app, we may send the error to some remote logging infrastructure
     // instead of just logging it to the console
     console.error(error);
     return Observable.throw(error.json().error || 'Server error');
 }
 /**
  * Handles any 400 or 500-level server responses by logging their details to the console.
  *
  * @param error
  * @returns {ErrorObservable}
  */
 protected handleError(error: any) : Observable<any> {
     let errMsg = (error.message) ? error.message :
         error.status ? `${error.status} - ${error.statusText}` : 'Server error';
     console.error(errMsg); // log to console instead
     return Observable.throw(errMsg);
 }
Example #14
0
    it('should use visibilityFilter to filter todos', () => {
      store.dispatch({ type: ADD_TODO, payload: { text: 'first todo' } });
      store.dispatch({ type: ADD_TODO, payload: { text: 'second todo' } });
      store.dispatch({
        type: COMPLETE_TODO,
        payload: { id: state.value.todos[0].id },
      });

      const filterVisibleTodos = (visibilityFilter: any, todos: any) => {
        let predicate;
        if (visibilityFilter === VisibilityFilters.SHOW_ALL) {
          predicate = () => true;
        } else if (visibilityFilter === VisibilityFilters.SHOW_ACTIVE) {
          predicate = (todo: any) => !todo.completed;
        } else {
          predicate = (todo: any) => todo.completed;
        }
        return todos.filter(predicate);
      };

      let currentlyVisibleTodos: Todo[] = [];

      Observable.combineLatest(
        store.pipe(select('visibilityFilter')),
        store.pipe(select('todos')),
        filterVisibleTodos
      ).subscribe(visibleTodos => {
        currentlyVisibleTodos = visibleTodos;
      });

      expect(currentlyVisibleTodos.length).toBe(2);

      store.dispatch({
        type: SET_VISIBILITY_FILTER,
        payload: VisibilityFilters.SHOW_ACTIVE,
      });

      expect(currentlyVisibleTodos.length).toBe(1);
      expect(currentlyVisibleTodos[0].completed).toBe(false);

      store.dispatch({
        type: SET_VISIBILITY_FILTER,
        payload: VisibilityFilters.SHOW_COMPLETED,
      });

      expect(currentlyVisibleTodos.length).toBe(1);
      expect(currentlyVisibleTodos[0].completed).toBe(true);

      store.dispatch({ type: COMPLETE_ALL_TODOS });

      expect(currentlyVisibleTodos.length).toBe(2);
      expect(currentlyVisibleTodos[0].completed).toBe(true);
      expect(currentlyVisibleTodos[1].completed).toBe(true);

      store.dispatch({
        type: SET_VISIBILITY_FILTER,
        payload: VisibilityFilters.SHOW_ACTIVE,
      });

      expect(currentlyVisibleTodos.length).toBe(0);
    });
Example #15
0
setAdapt(function adaptXstreamToRx(stream: Stream<any>): Observable<any> {
  return Observable.from(stream);
});
Example #16
0
 return (state$: Observable<SearchState>) => state$
   .select(s => s.query);
Example #17
0
 canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
   if (this.auth.isLoggedIn) {
     return Observable.of(true);
   }
   return Observable.of(false);
 }
Example #18
0
 var out:Observable<any> = Observable.fromEvent(this.elementRef.nativeElement, 'mouseout').map(e=> {
     return Observable.of(0)
 });
Example #19
0
 return this.matches$.flatMap((matches:Array<Match>) => {
   return Observable.of(this.filterMatchesByDayId(matches, PHASE_GROUP_MAX_DAY_ID))
     .flatMap((matches:Array<Match>) => {
       return this.associateWithUserBet(matches);
     });
 });
 err=> {
     var localDataStream = Observable.of([1,2,3]);
     return localDataStream;
 })
 .catch((error: any): any => {
     this.router.navigate([homeUrl]);
     this.dialogService.showErrorMessage('No site log found for ' + fourCharacterId);
     console.log(error);
     return Observable.empty();
 });
 this.listProvider = () => {
   return Observable.of([
     {id: 1, email: 'test1@test.com', name: 'test1', relationshipId: 1},
     {id: 2, email: 'test2@test.com', name: 'test2', relationshipId: 100},
   ]);
 };
Example #23
0
 return (state$: Observable<AppState>) => state$
     .select(s => s.products);
Example #24
0
 query(params = {}): Observable<Article> {
   return Observable.from(items).filter((item)=>!item.hidden);
 }
Example #25
0
 protected handleError(error: Response) {
     console.error(error);
     return Observable.throw(error.json().error || 'Server error');
 }
 ngOnInit() {
   this.scraping_subscription = this.scraping$.subscribe(
     (scraping: MultipleComicsScraping) => {
       this.scraping = scraping;
     });
 }
Example #27
0
 private handleError (error: any) {
     let errMsg = (error.message) ? error.message :
     error.status ? `${error.status} - ${error.statusText}` : 'Server error';
     console.error(errMsg);
     return Observable.throw(errMsg);
 }
Example #28
0
 .catch(error=>Observable.throw(error));
 isLoggedIn: () => Observable.of(false),
 .catch(error => {
     console.error(error);
     return Observable.throw(error.json())
 });