Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

angular wait all subscriptions

// Concat 
let first = Observable.timer(10,500).map(r => {
  return {source:1,value:r};
}).take(4);
let second = Observable.timer(10,500).map(r => {
  return {source:2,value:r};
}).take(4);
first.concat(second).subscribe(res => this.concatStream.push(res));
// This will merge the two but you will receive the first observable result before the second:
// 0 1 2 3 0 1 2 3

// Merge
let first = Observable.timer(10,500).map(r => {
  return {source:1,value:r};
}).take(4);
let second = Observable.timer(10,500).map(r => {
  return {source:2,value:r};
}).take(4);
first.merge(second).subscribe(res => this.mergeStream.push(res));

// You will get:
// 0 0 1 1 2 2 3 3

// Fork Join
let first = Observable.of({source:1,value:1});
let second = Observable.of({source:2,value:1});
Observable.forkJoin(first,second).subscribe((res:Array) => this.forkJoinStream = res);

// FlatMap
let first = Observable.of(10);
first.flatMap((operand1) => {
  return Observable.of(operand1 + 10);
})
.subscribe(res => this.flatMappedStreams = {msg: '10 + 10 = ' + res});
Comment

PREVIOUS NEXT
Code Example
Javascript :: box shadow in react native 
Javascript :: type of data model mongodb 
Javascript :: rxjs map 
Javascript :: javascript credit card validation 
Javascript :: vue dynamic route push with params 
Javascript :: toaster for angular 
Javascript :: count word and space in text javascript 
Javascript :: how to use jquery timepicker 
Javascript :: string reverse javascript 
Javascript :: disable key enter react-hook-form 
Javascript :: iiee i 
Javascript :: get url react 
Javascript :: node exporter service 
Javascript :: how to send a message using discord.js 
Javascript :: create an attribute for html with javascript 
Javascript :: click right mouse javascript 
Javascript :: how to add js in flask 
Javascript :: embed example discord.js 
Javascript :: javascript refresh page 
Javascript :: react native modal not full screen 
Javascript :: how to find length of a assocative array vuejs 
Javascript :: ajax request in javascript 
Javascript :: nodejs binary string to decimal number 
Javascript :: how to know if a number has a decimal number js 
Javascript :: toggle state react 
Javascript :: cannot get issue in nodejs 
Javascript :: import js file into another 
Javascript :: vue config devtools 
Javascript :: react hook form with yup resolver 
Javascript :: js tab character 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =