Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

RxJS TakeUntil

@Component({
  selector: "app-flights",
  templateUrl: "./flights.component.html"
})
export class FlightsComponent implements OnDestroy, OnInit {
  private readonly destroy$ = new Subject();

  public flights: FlightModel[];

  constructor(private readonly flightService: FlightService) {}

  ngOnInit() {
    this.flightService
      .getAll()
      .pipe(takeUntil(this.destroy$))
      .subscribe(flights => (this.flights = flights));
  }

  ngOnDestroy() {
    this.destroy$.next();
    this.destroy$.complete();
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: useeffect componentdidmount 
Javascript :: send a message in every guild discord.js 
Javascript :: how to make a 3*3 grid using html,css and javascript 
Javascript :: new function in javascript 
Javascript :: knex pagination plugin 
Javascript :: vue v-for loop array 
Javascript :: blockchain javascript 
Javascript :: fill in javascript 
Javascript :: arcgis for javascript 
Javascript :: filtering jquery 
Javascript :: javascript frames 
Javascript :: run javascript in atom 
Javascript :: make a component update every second react 
Javascript :: deploying multiple sites in firebase 
Javascript :: modal multiple images 
Javascript :: get all recod from db nodejs mongodb 
Javascript :: js standard global 
Javascript :: string to array in js 
Javascript :: react native image picker 
Javascript :: check if javascript function is true 
Javascript :: sorting the object 
Javascript :: angular auth guard 
Javascript :: datepicker range npm reactjs 
Javascript :: check the type of a variable in js 
Javascript :: javascript destructuring 
Javascript :: fetch in vue 3 
Javascript :: ternary javascript 
Javascript :: copy to clipboard jquery 
Javascript :: belongstomany sequelize 
Javascript :: mui animation 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =