And what if in the future I will need to merge with another observable that 
returns lets say string, now I will have strings coming back from 2 
different observables.
How to tell them apart?



On Thursday, April 20, 2017 at 1:15:48 PM UTC-7, Reza Razavipour wrote:
>
> so now I have two observables and need to run at the same time, in 
> parallel, so I merge the last 2 observables.
>
> getConfigurationSettings()
>
>     .do(config => {
>
>         console.log('we got the configuration settings.');
>
>         this.configSettings = config;
>
>     })
>
>     .switchMap(config => this.askForPatientContextWSAddress())
>
>     .do(config => {
>
>         this.subscriptionService.setWS(this.contextWS);
>
>         this.contextWS.onopen =  (evt) => {
>
>             this.contextWS.send("Hello World");
>
>         };
>
>     })
>
>     .switchMap(r => this.processContextChanges())
>
>     .merge(numbers)
>
>     .merge(modelUpdater)
>
>     .subscribe(
>
>         x => {
>
>             console.log('got data ' + x);
>
>         },
>
>         err => {
>
>             console.log(err);
>
>         },
>
>         () => console.log('app exiting'));
>
>
> Works as expected, in the subscription block where i receive data, how do 
> I tell which observable the data is from? yes the types of data coming back 
> is different, number or string or object. Is that what I should key off of?
>
>
> What is the correct way to manage this?
>
>
>
>
> On Wednesday, April 12, 2017 at 1:13:28 PM UTC-7, Reza Razavipour wrote:
>>
>>
>> This is a follow on to an original posting that I could not find anymore 
>> :(
>>
>> At application start time, I need to perform the following async tasks:
>>
>>    - Load a config file
>>    - Retrieve a server address from the config data and request a new 
>>    model every 10 seconds.
>>    - Using the above mentioned server, make an HTTP get call and receive 
>>    a websocket address.
>>    - Listen on data coming in on the websocket.
>>    
>>
>> I am trying to figure out to chain this action together and run 
>> sequentially.
>> Each of the above mentioned tasks are observables that I need to 
>> subscribe to.
>>
>> I am trying to figure out how do the chaining using RxJS and looking at 
>> switchMap.
>> Great so that chains all of my observables into 1, correct?
>>
>> If so, where do specify the subscriptions and actions to perform when 
>> there is data to process?
>>
>> Any ideas or explanations?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to