Angular/rxjs: Why don't I have to import toPromise anymore?

Angular/rxjs: Why don't I have to import toPromise anymore?

By : J. Bush
Date : November 20 2020, 03:01 PM
With these it helps A ton of SO answers say that to avoid problems like , As of rxjs 5.5.0-beta.5
code :

Share : facebook icon twitter icon
Has no exported member 'toPromise' rxjs- 5.5.2

Has no exported member 'toPromise' rxjs- 5.5.2

By : west azarbayjan tour
Date : March 29 2020, 07:55 AM
With these it helps As of rxjs 5.5.0-beta.5, the toPromise method is now a permanent method of Observable.
There is no need to import this method anymore; in fact, trying to do so will throw an error.
I dont get rxjs 6 with angular 6 with interval, switchMap, and map

I dont get rxjs 6 with angular 6 with interval, switchMap, and map

By : hero
Date : March 29 2020, 07:55 AM
it should still fix some issue The code should be something like the following. You need to use the pipe operator.
code :
import { interval } from 'rxjs';
import { switchMap, map } from 'rxjs/operators';

const result = interval(5000).pipe(
switchMap(() => this._authHttp.get(url)),    
map(res => res.results)
RxJS .toPromise returns only one value

RxJS .toPromise returns only one value

By : Gabi Toma
Date : March 29 2020, 07:55 AM
should help you out This will turn all values from your observable stream into an array and resolve the array as a promise value.
code :
).toPromise().then(val => console.log(val))
Angular 6 'rxjs/Rx'; observable first() dont work

Angular 6 'rxjs/Rx'; observable first() dont work

By : Mary_StackID
Date : March 29 2020, 07:55 AM
this one helps. PHOTOS is an array so when you do of(PHOTOS) it will create an observable that will emit that array as the first value. When you use the first method it will work, meaning it will return only the first item emitted by the observable, but in this case it's an array with all the values.
If you want to create an observable that will emit individual items from each item in the array you need to use the from method from(PHOTOS). In this case first will work as you expect.
RXJS 6 - toPromise

RXJS 6 - toPromise

By : Ricardo
Date : March 29 2020, 07:55 AM
this one helps. Im guessing that nothing happens because when you trigger the save method, nothing comes out of the authState. Apparently you expect that the authState observable or Subject will always trigger some output, which is only the case in specific cases.
The code below creates a -new- observable that listens to authState.
code :
return this.auth.authState.pipe(map(res =>
        title: form.title, content: form.content, createdAt: new Date(), sid: key,
        uid: res.uid, username: res.displayName
    )).toPromise().then((story: Story) =>
      this.afStore.doc(`stories/${key}`).set(story).catch(err => err.message));
public save$: Subject<StoryForm> = Subject<StoryForm>();
private destroy$: Subject<any> = new Subject();

ngOnDestroy(): void {

onInit() {
    // the (click) eventhandler in your GUI should call save$.next(storyForm)
    // this will trigger this statement
        // withLatestFrom will fetch the last value from an observable, 
        // it still needs to be a ReplaySubject or ReplaySubject for this to work though!
        // it will pass an array down the pipe with the storyForm value, and the last value from authState
        // switchMap does the actual work: note that we do not return a value, 
        // but an observable that should that return a value soon, that is why we need switchMap!
        switchMap(([storyForm, authInfo]) => {
            // i am assuming the "set" method returns an observable
            // if it returns a Promise, convert it using fromPromise
            return this.afStore.doc(`stories/${key}`).set(story).pipe(
                // catchError needs to be on your api call
                catchError(err => console.log(err))
        // this will kill your subscriptino when the screen dies
    ).subscribe(value => {
        // "value" will be the return value from the "set" call
Related Posts Related Posts :
  • Angular 4 Force navigate with refresh
  • Query dom element's properties Angular 4
  • Angular Material Dialog return value
  • Accessing HTTP Error Response Body from HttpInterceptor in Angular
  • Resolve Adal Token for Http Interceptor
  • Is it possible to change namespace name in @nrwl/nx?
  • Angular 4 Router: Getting redirected inside children's first route
  • Uncaught Error: Template parse error There is not such directive with exportAs
  • How can I use @HostListener('window:beforeunload') to call a method?
  • Is it possible to get the type from a generic, given as parameter
  • Ionic 3 - Preventing browser close
  • How to set the color of an icon in Angular Material?
  • how do i handle POST response
  • constructor being called duplicate in *ngFor due to @ViewChild
  • Angular4 OAuth2 IdentityServer4
  • ERROR TypeError: Cannot read property 'name' of undefined
  • Angular4 http get with URL parameter
  • What is the difference between fakeAsync's tick() and done() in angular2 testing?
  • How to push in service without losing previous data?
  • How to make custom arrow mark in agm-map?
  • Upload File in Angular 4 using FormData works in Local but not on Azure App Service
  • How to automatically deploy a Laravel app with embedded Angular to Heroku
  • Unexpected module 'Ng2SmartTableModule' declared by the module 'AppModule'
  • use angular-cli project with visual studio asp.net empty web app?
  • How to load different templates for the same component?
  • Creating Angular4 'Loading' Screen: ExpressionChangedAfterItHasBeenCheckedError
  • How to pass a array value as color in Angular 4
  • Coerce the HttpResponse into an item of the specified type, complete with custom methods
  • Angular 2 @Input not works for router outlet
  • Nested Model - Angular 2
  • Supress duplicate error in aot compiler
  • Angular2 ExpressionChangedAfterItHasBeenCheckedError
  • Consuming my promise inside my Angular component
  • Despite error cannot read property length of null, the code works
  • Accessing data returned by Promise.all
  • How to add background image with ngStyle?
  • Property X doesn't exist on type Y[]
  • Ionic Headers Failing to set through http.post
  • Angular 4 routing/state problems
  • Angular 2 Dashboard application web api call at initialization
  • ngrx/store:subscribe works fine but async in template gives [object Object]
  • Angular2 - how to mix custom and declared arguments in constructor
  • Implementing Geolocation from @ionic-native/geolocation
  • Angular - Test library before publish
  • AoT Compilation Failed - no such file or directory, lstat 'tsconfig-aot.json'
  • Docker container from Angular4 app : "-p" : executable file not found in $PATH
  • Invalid container name
  • Angular - NgStyle fall back image
  • Angular Observable not updating when I subscribe.
  • Angular mat-checkbox getElementById
  • Angular 4 Injecting route in the APP_INITIALIZER
  • Error: EACCES: Error: EACCES: permission denied, open '/Users/emilio/.ionic/daemon.log' at Error (native)
  • selected value in dropdown list does not work Angular
  • how to smooth scroll down to element on page load angular 4?
  • AngularFire update breaks the app
  • experimentalDecorators Warning on ts lint
  • Dexie - Check if a record exists and initialize it if not present
  • How should I use BehaviorSubject class from a Service in the HTML Template of a Component in Angular 4?
  • How to make ngx-bootstrap datepicker be able to select and display only month and year?
  • What is wrong with this Angular form that makes it reset selected values in the UI unexpectedly?
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org