• +91 9723535972
  • info@interviewmaterial.com

RxJS Interview Questions and Answers

RxJS Interview Questions and Answers

Question - 41 : -
What is Subscriptions ?

Answer - 41 : -

  • Subscriptions are objects returned when an Observable is subscribed.
  • Listening to the stream is called subscribing.

Question - 42 : -
What is Subject ?

Answer - 42 : -

  • Subjects are unique types of Observers, that enables you to subscribe to other Observables and also listen to published data
  • Listening to the stream is called subscribing.

Question - 43 : -
What is RxJS concatMap?

Answer - 43 : -

ConcatMap is a combination of 2 operators(concat and map), it lets us mapping a value from a source observable to an observale stream.When the inner observable lets it valoue and pass it down to an observable.It helps in collecting all the emitted values from all of the inner observables and emits it into the subscribers.
Concat is used for taking each form value and in transforming into an observer HTTP,known as inner observer.It also helps in subscribing to the inner observable and also sends the output to the observable result.

Question - 44 : -
What are switchMap, mergeMap and concatMap?

Answer - 44 : -

These are the operators used to flatten the observables, they are applicable in different scenerios.Switvh and Merge maps are the most powerful and they are frequently used as the operators.
Mergemap used in creating an observable immediately for any other source item and it keeps the observables alive.
Concatmap are used for crating a new observable.
Switchmap helps in completing the previous observable and creates the next observable.

Question - 45 : -
What is the use of mergeMap?

Answer - 45 : -

mergeMap os also known as flatmap, which is used for flattening an inner observable and also in controlling the number of inner subscription.It also helps in maintaining multiple active inner subscription at once.
It starts emitting the values from replacing the original values and it does not cancle any of the inner observables.
Here is an example of mergeMap:
mergeMap(project: (value: T, index: number) => O): OperatorFunction>

Question - 46 : -
What is Angular Material?

Answer - 46 : -

Angular Material is a UI component which helps in creating attractive, consistent and fully functional web pages, it includes browser portability and graceful degradation.Angular Material has good performance as every millisecond counts.
For using Angular Material components, you need to import the appropriate modules. We will do this in the APP-module:
import { MatCardModule } from '@angular/material/card';
import { MatListModule } from '@angular/material/list';
import { MatButtonModule } from '@angular/material/button';
import { MatDialogModule } from '@angular/material/dialog';
import { MatInputModule } from '@angular/material/input';
import { MatIconModule } from '@angular/material/icon';
import { MatDividerModule } from '@angular/material/divider';
 
@NgModule({
  imports: [
    MatCardModule,
    MatListModule,
    MatButtonModule,
    MatDialogModule,
    MatInputModule,
    MatIconModule,
    MatDividerModule,
  ],
})

Question - 47 : -
What are the key features of Angular?

Answer - 47 : -

The key features of the Angular are as follows:
  • Templates
  • Model View Controller
  • Dependency Injection
  • Directive
  • Code splitting
  • Validation
  • Testing
  • Data Binding
  • Localization

Question - 48 : -
How can we get current value of RxJS Subject or Observable?

Answer - 48 : -

The observable and subjects does not have a current value, and is emitted or passed to the subcribers and yhe observable is done with it.If we want to have the current or uses BehaviorSubject that is designed for this purpose.As it keeps the emitted value and emits to new subscribers.
import {Storage} from './storage';
import {Injectable} from 'angular2/core';
import {Subject}    from 'rxjs/Subject';

@Injectable()
export class SessionStorage extends Storage {
  private _isLoggedInSource = new Subject();
  isLoggedIn = this._isLoggedInSource.asObservable();
  constructor() {
    super('session');
  }
  setIsLoggedIn(value: boolean) {
    this.setItem('_isLoggedIn', value, () => {
      this._isLoggedInSource.next(value);
    });
  }
}

Question - 49 : -
How can we close a dropdown on click outside?

Answer - 49 : -

export class UserMenuComponent {

    _isVisible: boolean = false;
    _subscriptions: Subscription = null;

    constructor(public subjects: SubjectsService) {
    }

    onClick(event) {
        event.stopPropagation();
    }

    set isVisible(v) {
        if( v ){
            setTimeout( () => {
this._subscriptions =  this.subjects.userMenu.subscribe((e) => {
                       this.isVisible = false;
                       })
            }, 0);
        } else {
            this._subscriptions.unsubscribe();
        }
        this._isVisible = v;
    }

    get isVisible() {
        return this._isVisible;
    }
}

Question - 50 : - What is the Reactive Manifesto?

Answer - 50 : -

The Reactive Manifesto is a document that defines the core principles of reactive programming. It was first released in 2013 by a group of developers led by a man called Jonas Boner. The Reactive Manifesto underpins the principles of reactive programming.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners