JavaScript RxJs reactive map is called twice when once is sufficient

In the example below, map is called twice per onNext call which is unnecessary, because the same value for ds can be reused for the two observers. How to write the code such that the map is only called once per onNext call? Or should I use promise?

var subject = new Rx.BehaviorSubject(42);

var ds = subject.map(function(x) {
        console.log("processing");
        return x + 100;
});

var subscription1 = ds.subscribe(
    function (x) {
        console.log('first observed: ' + x.toString());
    }
);

var subscription2 = ds.subscribe(
    function (x) {
        console.log('second observed: ' + x.toString());
    }
);

subject.onNext(56);
subject.onNext(134);
Answer:1

I am not able to set maximum height on the slider I am using, every height I set doesn't seem to be working. I have also tried setting the width on echo img row on the php part but it is not working. ...

I am not able to set maximum height on the slider I am using, every height I set doesn't seem to be working. I have also tried setting the width on echo img row on the php part but it is not working. ...

  1. setting height 100 not working
  2. setting div height not working
  3. jquery setting height not working

I have a lot of problems in my code because it is not synchronous. Here is an example of problem that i have in a chrome extension. This is my function function getTranslation(a_data, callback) { ...

I have a lot of problems in my code because it is not synchronous. Here is an example of problem that i have in a chrome extension. This is my function function getTranslation(a_data, callback) { ...

  1. javascript synchronous functions
  2. js synchronous functions
  3. javascript synchronous callback
  4. javascript synchronous calls
  5. javascript synchronous method
  6. javascript synchronous method call
  7. js synchronous callback
  8. js synchronous method
  9. javascript callback synchronous or asynchronous
  10. node js synchronous functions
  11. javascript synchronous and asynchronous functions
  12. javascript make functions synchronous
  13. javascript synchronous vs asynchronous functions

I want to reload a template and the connected Controller without using $routeProvider, because my Path-structure doesn't fit with .when(...). I want to use $location.path() to read the URL and set the ...

I want to reload a template and the connected Controller without using $routeProvider, because my Path-structure doesn't fit with .when(...). I want to use $location.path() to read the URL and set the ...

  1. angular reload template
  2. angular 6 reload template
  3. angular directive reload template
  4. angular 2 reload template
  5. angular force reload template
  6. angular 2 reload component template
  7. angular 2 force template reload
  8. angularjs reload template

Currently having a problem in a app. My app is designed to open an RFID reader on a Raspberry PI. It proceeds to read the incoming RFID tags. The code is as follows; // Socket.io server details var ...

Currently having a problem in a app. My app is designed to open an RFID reader on a Raspberry PI. It proceeds to read the incoming RFID tags. The code is as follows; // Socket.io server details var ...