demos/03-concurrent-fruit.js
function getUserInputFromStdin() {
    // set up stdin
    const keypress = require("keypress")
    keypress(process.stdin)
    process.stdin.setRawMode(true)
    process.stdin.resume()

    // A Subject is something that you can push values at, and
    // it can be subscribed to as an Observable of those values
    const s = new Subject()

    // set up handler and return the stream as Observable
    process.stdin.on("keypress", (ch, key = {}) => {
      if (key.name == "x" || (key && key.ctrl && key.name == "c")) {
        process.stdin.pause()
        s.complete()
        log("\nBye!")
        process.exit()
      }
      if (ch === "0" || Number(ch)) {
        s.next(Number(ch))
      } else {
        process.stdin.pause()
        log("Not 0-9.\nBye!")
        s.complete()
      }
    })

    return s.asObservable()
  }
function getUserInputFromStdin() {
    // set up stdin
    const keypress = require("keypress")
    keypress(process.stdin)
    process.stdin.setRawMode(true)
    process.stdin.resume()

    // A Subject is something that you can push values at, and
    // it can be subscribed to as an Observable of those values
    const s = new Subject()

    // set up handler and return the stream as Observable
    process.stdin.on("keypress", (ch, key = {}) => {
      if (key.name == "x" || (key && key.ctrl && key.name == "c")) {
        process.stdin.pause()
        s.complete()
        log("\nBye!")
        process.exit()
      }
      if (ch === "0" || Number(ch)) {
        s.next(Number(ch))
      } else {
        process.stdin.pause()
        log("Not 0-9.\nBye!")
        s.complete()
      }
    })

    return s.asObservable()
  }
function getUserInputFromStdin ( ) { // set up stdin const keypress = require ( "keypress" ) keypress ( process . stdin ) process . stdin . setRawMode ( true ) process . stdin . resume ( ) // A Subject is something that you can push values at, and // it can be subscribed to as an Observable of those values const s = new Subject ( ) // set up handler and return the stream as Observable process . stdin . on ( "keypress" , ( ch , key = { } ) => { if ( key . name == "x" || ( key && key . ctrl && key . name == "c" ) ) { process . stdin . pause ( ) s . complete ( ) log ( "\nBye!" ) process . exit ( ) } if ( ch === "0" || Number ( ch ) ) { s . next ( Number ( ch ) ) } else { process . stdin . pause ( ) log ( "Not 0-9.\nBye!" ) s . complete ( ) } } ) return s . asObservable ( ) }
get a stream - like a promise that keeps emitting events over time which you get via subscribing
get a stream - like a promise that keeps emitting events over time which you get via subscribing