I started writing a simple game script, but I ran into a problem.
The code creates 2 streams - player , walls :
const Helper = function() { this.randomIntFromZero = function(maxExclusive) { return Math.floor(Math.random() * (maxExclusive)); }; }; helper = new Helper(); const move = Rx.Observable.fromEvent(document, 'keydown'); const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); document.body.appendChild(canvas); canvas.width = 200; canvas.height = 200; const WALLLS_CNT = 10; const wallWidth = 16; const wallHeight = 16; const wallColor = '#ccc'; const walls = Rx.Observable .range(1, 10) .map(() => { return { x: helper.randomIntFromZero(canvas.width - wallWidth), y: helper.randomIntFromZero(canvas.height - wallHeight) }; }) const deltaCoord = 5; const canvasColor = '#fff'; const player = move.map( e => { const coords = { x: 0, y: 0 } if (e.keyCode == 37) { coords.x -= (player.x <= 0) ? 0 : deltaCoord; } if (e.keyCode == 38) { coords.y -= (player.y <= 0) ? 0 : deltaCoord; } if (e.keyCode == 39) { coords.x += (player.x + player.width >= canvas.width) ? 0 : deltaCoord; } if (e.keyCode == 40) { coords.y += (player.y + player.width >= canvas.height) ? 0 : deltaCoord; } return coords; } ) .startWith({ x: 0, y: 0 }) Rx.Observable.combineLatest((player, walls) => { console.log(player, walls); }) .subscribe((player, walls) => { console.log('player', player); console.log('walls', walls); }); <script src="https://unpkg.com/rxjs@5.5.2/bundles/Rx.min.js"></script> The problem is that console.logs from the last piece of code are not displayed in the console.