The Console.Log function will not run if it is placed within the RXJS Tap operator

In my current setup, I have the following observables:

this.authenticationService.isSignedIn() -> Observable<Boolean>

this.user$ -> Observable<UserModel>

I am in need of checking a condition based on both these observables, so I attempted the following approach:

zip(this.authenticationService.isSignedIn(), this.user$).pipe(
  map(([isSignedIn, user]: [boolean, UserModel]) => isSignedIn && user.claims))
); 

However, the result I received was unexpected. To further investigate the issue, I utilized the following method:

zip(this.authenticationService.isSignedIn(), this.user$).pipe(
  tap(([isSignedIn, user]: [boolean, UserModel]) => {
    console.log(isSignedIn);
    console.log(user);
  })
);

Surprisingly, the console.log statements did not execute as expected. What could be the possible explanation for this behavior?

Answer №1

Perhaps you are overlooking a subscription. All RxJS operations are lazy and will not execute until a subscription is made. If you only need to process the result using the tap operator, simply include .subscribe() at the end.

zip(...).pipe(
  tap(...)
).subscribe();

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Clearing error messages from a form using the reset button or after cancelling the form

I am having trouble removing the error outline around the input box and error messages displayed below it. When I cancel the form or click on the reset button, the input fields' content along with the error messages should be cleared. However, current ...

Get a list of images by incorporating NextJs and Strapi to create a dynamic slider feature

[] I need help creating a slider as I am encountering an error when trying to output an array of objects. The error can be seen here: https://i.sstatic.net/HHOaB.png. Can someone assist me in resolving this issue? Thank you. Here is a screenshot from the ...

How can I redirect a remote image URL to a local folder during development?

Currently, I am pulling image URLs from a database that was dumped from the production server. An example of one of these URLs is https://example.com/imageStorage/photo.jpg. These URLs are then used to display images in HTML templates using the following f ...

Angular implementation of the scroll down effect in bootstrap navigation

I have integrated a bootstrap template into my Angular web application, specifically using this template. If you visit the live preview, you will notice a scroll-down effect on the navigation bar. You can find the code for this navigation bar effect here: ...

Assigning values to objects based on the types of their properties in Typescript

In my Redux store, I want to create a reducer that can modify any attribute values within the store. Consider the state object defined with specific types: type StoreState = { admins: Admin[]; messages: Message[]; pageInformation: PageInformation; } ...

What is the best way to differentiate between the legend and chart when working with three separate

I have encountered an issue with my pie charts. The first chart has 10 legends displayed below it, while the second chart only has 4 legends. When I adjust the padding to accommodate the 10 legends in the first chart, the names of the 4 legends in the se ...

Exploring the concepts of Indigenous Unity within Angular 17

Currently, I am handling a project in Angular 17 that implements the micro frontend concept, specifically utilizing Native Federation. I have followed the instructions provided on the official website, and everything is functioning correctly. However, I am ...

What is the best way to send {...rest} properties to a text field in react material?

When using a material textfield inside a wrapper component and passing the remaining props as {...otherprops} in a JavaScript file, everything works fine. However, when attempting to do the same in TypeScript, an error occurs. const TextFieldWrapper = (pro ...

Troubleshooting property assignment issues within an Angular service

I have created a simple injectable service in TypeScript for Angular 4. This service is designed to fetch a JSON file from the network and store the data as an array in its property called data. Other classes can then access this data using the method getD ...

Having trouble utilizing a JavaScript file within TypeScript

I am currently exploring the integration of Three.js into an Angular application. Following the documentation, I imported Three.js using the following line: import * as THREE from 'three'; In addition, I installed the types for Three.js with th ...

What is the best approach for transferring non-string objects between routes in Angular?

I am currently developing a custom file viewer. To achieve this, I have created a specialized component known as FileBrowserComponent that is specifically designed to be displayed when the route /files is accessed. When navigating, I include a query param ...

Deleting an element from an array in Mongodb using Angular

My question remains unanswered: Delete an element from an array of an array in MongoDb In the process of creating a basic MEAN application similar to Stack Overflow, I have encountered an issue. Within my application, there are articles with upvotes and d ...

Angular tree grid with advanced data buffering functionality

Currently, I am working with angular 7 and in need of a tree grid plugin that includes a buffering feature for loading a large quantity of records. The goal is to load only the visible part of the record initially, then progressively load additional reco ...

I'm encountering an issue with my launch.json file where an error is being triggered on the line that contains "program": "${workspaceFolder}\serve". What could be causing this error?

Whenever I attempt to start the debugger for my Angular application, I encounter the following error message: "Attribute 'program' does not exist ('C:\repos\recipes\serve') I have already attempted to remove the pre-exi ...

Display fresh information that has been fetched via an HTTP request in Angular

Recently, I encountered an issue where data from a nested array in a data response was not displaying properly in my component's view. Despite successfully pushing the data into the object programmatically and confirming that the for loop added the it ...

What is the best way to compare dates in order to obtain the necessary results?

Question : Filter the JSON array to retrieve specific entries 1: All entries with name "Sam". 2: All entries with date "Dec 2019". // JSON Data provided below. var data = [{ "id":"27", "0":{ "name":"Sam", "date":"2021-02-28" ...

What steps can be taken to resolve the issue of being unable to rename an element in Typescript?

Why does VS code editor sometimes prevent me from renaming my typescript symbol using the f2 key? I keep encountering the error message "This element cannot be renamed." https://i.stack.imgur.com/mmqu9.png In some of my other projects, I am able to renam ...

Issues with property binding in Angular are causing problems

Suppose the app component has a variable defined for the value in the input field. However, every time the button event is triggered, the string is printed as empty and the binding does not seem to work at all. export class AppComponent { numVal =1235; ...

Encounter a net::ERR_EMPTY_RESPONSE error while trying to deploy an Angular application on a production server

I have successfully developed an Angular App on my local machine and now I am facing challenges while trying to deploy it on a Windows production server. I have set up Apache to serve the App along with the Rest Service API. Accessing the App through the ...

Angular POST sends null to .NET Core API

I've been encountering an issue while trying to send data from Angular to my .NET Core API, as the received data always ends up being null. Take a look at my code: Here is the Angular POST request: public insertCategory(categoryToInsert: ICategoryDTO ...