this is the scenario:
I have multiple connection to different databases and i want to be sure that code runs whenever all connections are active.
I am using Rxjs to handle this (another solution is welcome ) but im facing that if i combine the connection events AFTER one of them is active i never get the subscription run, since combineLatest wants all observables to be emitted, but they were !
const a = new Rx.Subject();
const b = new Rx.Subject();
var bool = false;
setInterval(()=>{
bool = !bool
a.next(bool ? ' i am connected' : 'im NOT connected');
},1000)
setTimeout(()=>{
b.next('i am always connected!')
},400)
// this variable will be exported to all js that run queries
var obs = new Rx.Observable.combineLatest(a,b);
setTimeout(()=>{
obs.subscribe((andb)=>{
console.log( andb )
// i can check all connections at once and run the code
})
},399)
// problem is here, i want to subscribe later than the connections
//emit, if you edit 399 to 401 you will see that nothing is going on
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/5.5.6/Rx.js"></script>