├── LICENSE ├── README.md ├── step00_helloworld_node ├── .gitignore ├── .vscode │ └── tasks.json ├── app.js ├── app.js.map ├── app.ts ├── package.json ├── readme.md ├── tsconfig.json ├── typings.json └── typings │ ├── globals │ ├── core-js │ │ ├── index.d.ts │ │ └── typings.json │ └── node │ │ ├── index.d.ts │ │ └── typings.json │ └── index.d.ts ├── step01_helloworld_browser ├── .gitignore ├── .vscode │ └── tasks.json ├── app │ ├── main.js │ ├── main.js.map │ └── main.ts ├── index.html ├── package.json ├── readme.md ├── systemjs.config.js ├── tsconfig.json ├── typings.json └── typings │ ├── globals │ ├── core-js │ │ ├── index.d.ts │ │ └── typings.json │ └── node │ │ ├── index.d.ts │ │ └── typings.json │ └── index.d.ts ├── step02_filter ├── .gitignore ├── .vscode │ └── tasks.json ├── app │ ├── main.js │ ├── main.js.map │ └── main.ts ├── index.html ├── package.json ├── readme.md ├── systemjs.config.js ├── tsconfig.json ├── typings.json └── typings │ ├── globals │ ├── core-js │ │ ├── index.d.ts │ │ └── typings.json │ └── node │ │ ├── index.d.ts │ │ └── typings.json │ └── index.d.ts ├── step03_create ├── .gitignore ├── .vscode │ └── tasks.json ├── app.js ├── app.js.map ├── app.ts ├── package.json ├── readme.md ├── tsconfig.json ├── typings.json └── typings │ ├── globals │ ├── core-js │ │ ├── index.d.ts │ │ └── typings.json │ └── node │ │ ├── index.d.ts │ │ └── typings.json │ └── index.d.ts ├── step04_ajax ├── .gitignore ├── .vscode │ └── tasks.json ├── app │ ├── contents.json │ ├── main.js │ ├── main.js.map │ └── main.ts ├── index.html ├── package.json ├── readme.md ├── systemjs.config.js ├── tsconfig.json ├── typings.json └── typings │ ├── globals │ ├── core-js │ │ ├── index.d.ts │ │ └── typings.json │ └── node │ │ ├── index.d.ts │ │ └── typings.json │ └── index.d.ts ├── step05_create_from_array ├── .gitignore ├── app.js ├── app.js.map ├── app.ts ├── package.json ├── readme.md ├── tsconfig.json ├── typings.json └── typings │ ├── globals │ ├── core-js │ │ ├── index.d.ts │ │ └── typings.json │ └── node │ │ ├── index.d.ts │ │ └── typings.json │ └── index.d.ts ├── step06_merge ├── .gitignore ├── app.js ├── app.js.map ├── app.ts ├── npm-debug.log ├── package.json ├── readme.md ├── tsconfig.json ├── typings.json └── typings │ ├── globals │ ├── core-js │ │ ├── index.d.ts │ │ └── typings.json │ └── node │ │ ├── index.d.ts │ │ └── typings.json │ └── index.d.ts ├── step07_map ├── .gitignore ├── .vscode │ └── launch.json ├── app.js ├── app.js.map ├── app.ts ├── package.json ├── readme.md ├── tsconfig.json ├── typings.json └── typings │ ├── globals │ ├── core-js │ │ ├── index.d.ts │ │ └── typings.json │ └── node │ │ ├── index.d.ts │ │ └── typings.json │ └── index.d.ts ├── step08_filter_even ├── .gitignore ├── .vscode │ └── launch.json ├── app.js ├── app.js.map ├── app.ts ├── package.json ├── readme.md ├── tsconfig.json ├── typings.json └── typings │ ├── globals │ ├── core-js │ │ ├── index.d.ts │ │ └── typings.json │ └── node │ │ ├── index.d.ts │ │ └── typings.json │ └── index.d.ts ├── step09_reduce ├── .gitignore ├── .vscode │ └── launch.json ├── app.js ├── app.js.map ├── app.ts ├── package.json ├── readme.md ├── tsconfig.json ├── typings.json └── typings │ ├── globals │ ├── core-js │ │ ├── index.d.ts │ │ └── typings.json │ └── node │ │ ├── index.d.ts │ │ └── typings.json │ └── index.d.ts ├── step10_reduce_average ├── .gitignore ├── .vscode │ └── launch.json ├── app.js ├── app.js.map ├── app.ts ├── package.json ├── readme.md ├── tsconfig.json ├── typings.json └── typings │ ├── globals │ ├── core-js │ │ ├── index.d.ts │ │ └── typings.json │ └── node │ │ ├── index.d.ts │ │ └── typings.json │ └── index.d.ts ├── step11_scan ├── .gitignore ├── .vscode │ └── launch.json ├── app.js ├── app.js.map ├── app.ts ├── package.json ├── readme.md ├── tsconfig.json ├── typings.json └── typings │ ├── globals │ ├── core-js │ │ ├── index.d.ts │ │ └── typings.json │ └── node │ │ ├── index.d.ts │ │ └── typings.json │ └── index.d.ts ├── step12_subject ├── .gitignore ├── .vscode │ └── tasks.json ├── app.js ├── app.js.map ├── app.ts ├── package.json ├── readme.md ├── tsconfig.json ├── typings.json └── typings │ ├── globals │ ├── core-js │ │ ├── index.d.ts │ │ └── typings.json │ └── node │ │ ├── index.d.ts │ │ └── typings.json │ └── index.d.ts ├── step13_behavior_subject ├── .gitignore ├── .vscode │ └── tasks.json ├── app.js ├── app.js.map ├── app.ts ├── package.json ├── readme.md ├── tsconfig.json ├── typings.json └── typings │ ├── globals │ ├── core-js │ │ ├── index.d.ts │ │ └── typings.json │ └── node │ │ ├── index.d.ts │ │ └── typings.json │ └── index.d.ts ├── step14_replay_subject ├── .gitignore ├── .vscode │ └── tasks.json ├── app.js ├── app.js.map ├── app.ts ├── package.json ├── readme.md ├── tsconfig.json ├── typings.json └── typings │ ├── globals │ ├── core-js │ │ ├── index.d.ts │ │ └── typings.json │ └── node │ │ ├── index.d.ts │ │ └── typings.json │ └── index.d.ts ├── step15_async_subject ├── .gitignore ├── .vscode │ └── tasks.json ├── app.js ├── app.js.map ├── app.ts ├── package.json ├── readme.md ├── tsconfig.json ├── typings.json └── typings │ ├── globals │ ├── core-js │ │ ├── index.d.ts │ │ └── typings.json │ └── node │ │ ├── index.d.ts │ │ └── typings.json │ └── index.d.ts └── step_extra_browser_es5 ├── .gitignore ├── .vscode └── tasks.json ├── app └── main.js ├── index.html ├── package.json └── readme.md /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Panacloud (Pvt.) Ltd. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Learn Reactive Programming with RxJS 5 and TypeScript 2 | Learn [RxJS 5](https://github.com/ReactiveX/RxJS) using [TypeScript](https://github.com/panacloud/learn-typescript) in Baby Steps. 3 | 4 | Get started by Watching these videos: 5 | 6 | https://egghead.io/lessons/rxjs-reactive-programming-what-is-rxjs 7 | 8 | https://channel9.msdn.com/Shows/codechat/050 9 | 10 | Prerequsite: 11 | https://github.com/panacloud/learn-typescript 12 | 13 | For Installation instructions: 14 | https://github.com/ReactiveX/RxJS 15 | 16 | We will learn the theory from this book: 17 | http://www.amazon.com/Reactive-Programming-RxJS-Asynchronous-JavaScript-ebook/dp/B01ATYZTI4/ 18 | 19 | RxJS 5 Documentation: 20 | http://reactivex.io/rxjs/manual/overview.html 21 | 22 | Also Read: 23 | "Take what you need, learn about it, use it and move on. Don’t worry to understand everything at once (it’s overwhelming, I promise!)" 24 | 25 | http://juristr.com/blog/2016/06/rxjs-1st-steps-subject/ 26 | 27 | 28 | Operators by Example: 29 | 30 | https://gist.github.com/btroncone/d6cf141d6f2c00dc6b35 -------------------------------------------------------------------------------- /step00_helloworld_node/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /step00_helloworld_node/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // Available variables which can be used inside of strings. 2 | // ${workspaceRoot}: the root folder of the team 3 | // ${file}: the current opened file 4 | // ${fileBasename}: the current opened file's basename 5 | // ${fileDirname}: the current opened file's dirname 6 | // ${fileExtname}: the current opened file's extension 7 | // ${cwd}: the current working directory of the spawned process 8 | 9 | // A task runner that calls the Typescript compiler (tsc) and 10 | // Compiles a HelloWorld.ts program 11 | { 12 | "version": "0.1.0", 13 | 14 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 15 | "command": "tsc", 16 | 17 | // The command is a shell script 18 | "isShellCommand": true, 19 | 20 | // Show the output window only if unrecognized errors occur. 21 | "showOutput": "silent", 22 | 23 | // args is the HelloWorld program to compile. 24 | "args": ["app.ts"], 25 | 26 | // use the standard tsc problem matcher to find compile problems 27 | // in the output. 28 | "problemMatcher": "$tsc" 29 | } 30 | 31 | // A task runner that calls the Typescript compiler (tsc) and 32 | // compiles based on a tsconfig.json file that is present in 33 | // the root of the folder open in VSCode 34 | /* 35 | { 36 | "version": "0.1.0", 37 | 38 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 39 | "command": "tsc", 40 | 41 | // The command is a shell script 42 | "isShellCommand": true, 43 | 44 | // Show the output window only if unrecognized errors occur. 45 | "showOutput": "silent", 46 | 47 | // Tell the tsc compiler to use the tsconfig.json from the open folder. 48 | "args": ["-p", "."], 49 | 50 | // use the standard tsc problem matcher to find compile problems 51 | // in the output. 52 | "problemMatcher": "$tsc" 53 | } 54 | */ 55 | 56 | // A task runner configuration for gulp. Gulp provides a less task 57 | // which compiles less to css. 58 | /* 59 | { 60 | "version": "0.1.0", 61 | "command": "gulp", 62 | "isShellCommand": true, 63 | "tasks": [ 64 | { 65 | "taskName": "less", 66 | // Make this the default build command. 67 | "isBuildCommand": true, 68 | // Show the output window only if unrecognized errors occur. 69 | "showOutput": "silent", 70 | // Use the standard less compilation problem matcher. 71 | "problemMatcher": "$lessCompile" 72 | } 73 | ] 74 | } 75 | */ 76 | 77 | // Uncomment the following section to use jake to build a workspace 78 | // cloned from https://github.com/Microsoft/TypeScript.git 79 | /* 80 | { 81 | "version": "0.1.0", 82 | // Task runner is jake 83 | "command": "jake", 84 | // Need to be executed in shell / cmd 85 | "isShellCommand": true, 86 | "showOutput": "silent", 87 | "tasks": [ 88 | { 89 | // TS build command is local. 90 | "taskName": "local", 91 | // Make this the default build command. 92 | "isBuildCommand": true, 93 | // Show the output window only if unrecognized errors occur. 94 | "showOutput": "silent", 95 | // Use the redefined Typescript output problem matcher. 96 | "problemMatcher": [ 97 | "$tsc" 98 | ] 99 | } 100 | ] 101 | } 102 | */ 103 | 104 | // Uncomment the section below to use msbuild and generate problems 105 | // for csc, cpp, tsc and vb. The configuration assumes that msbuild 106 | // is available on the path and a solution file exists in the 107 | // workspace folder root. 108 | /* 109 | { 110 | "version": "0.1.0", 111 | "command": "msbuild", 112 | "args": [ 113 | // Ask msbuild to generate full paths for file names. 114 | "/property:GenerateFullPaths=true" 115 | ], 116 | "taskSelector": "/t:", 117 | "showOutput": "silent", 118 | "tasks": [ 119 | { 120 | "taskName": "build", 121 | // Show the output window only if unrecognized errors occur. 122 | "showOutput": "silent", 123 | // Use the standard MS compiler pattern to detect errors, warnings 124 | // and infos in the output. 125 | "problemMatcher": "$msCompile" 126 | } 127 | ] 128 | } 129 | */ 130 | 131 | // Uncomment the following section to use msbuild which compiles Typescript 132 | // and less files. 133 | /* 134 | { 135 | "version": "0.1.0", 136 | "command": "msbuild", 137 | "args": [ 138 | // Ask msbuild to generate full paths for file names. 139 | "/property:GenerateFullPaths=true" 140 | ], 141 | "taskSelector": "/t:", 142 | "showOutput": "silent", 143 | "tasks": [ 144 | { 145 | "taskName": "build", 146 | // Show the output window only if unrecognized errors occur. 147 | "showOutput": "silent", 148 | // Use the standard MS compiler pattern to detect errors, warnings 149 | // and infos in the output. 150 | "problemMatcher": [ 151 | "$msCompile", 152 | "$lessCompile" 153 | ] 154 | } 155 | ] 156 | } 157 | */ 158 | // A task runner example that defines a problemMatcher inline instead of using 159 | // a predfined one. 160 | /* 161 | { 162 | "version": "0.1.0", 163 | "command": "tsc", 164 | "isShellCommand": true, 165 | "args": ["HelloWorld.ts"], 166 | "showOutput": "silent", 167 | "problemMatcher": { 168 | // The problem is owned by the typescript language service. Ensure that the problems 169 | // are merged with problems produced by Visual Studio's language service. 170 | "owner": "typescript", 171 | // The file name for reported problems is relative to the current working directory. 172 | "fileLocation": ["relative", "${cwd}"], 173 | // The actual pattern to match problems in the output. 174 | "pattern": { 175 | // The regular expression. Matches HelloWorld.ts(2,10): error TS2339: Property 'logg' does not exist on type 'Console'. 176 | "regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$", 177 | // The match group that denotes the file containing the problem. 178 | "file": 1, 179 | // The match group that denotes the problem location. 180 | "location": 2, 181 | // The match group that denotes the problem's severity. Can be omitted. 182 | "severity": 3, 183 | // The match group that denotes the problem code. Can be omitted. 184 | "code": 4, 185 | // The match group that denotes the problem's message. 186 | "message": 5 187 | } 188 | } 189 | } 190 | */ -------------------------------------------------------------------------------- /step00_helloworld_node/app.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Rx = require('rxjs/Rx'); 3 | var simpleStream = Rx.Observable.of('hello world'); 4 | simpleStream.subscribe(function (value) { 5 | console.log(value); 6 | }); 7 | -------------------------------------------------------------------------------- /step00_helloworld_node/app.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":";AAAA,IAAO,EAAE,WAAW,SAAS,CAAC,CAAC;AAE/B,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,aAAa,CAAC;KAC5B,SAAS,CAAC,UAAS,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /step00_helloworld_node/app.ts: -------------------------------------------------------------------------------- 1 | import Rx = require('rxjs/Rx'); 2 | 3 | const simpleStream = Rx.Observable.of('hello world'); 4 | 5 | simpleStream.subscribe((value) => { 6 | console.log(value); 7 | }); 8 | 9 | -------------------------------------------------------------------------------- /step00_helloworld_node/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "step00_helloworld", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.ts", 6 | "devDependencies": {}, 7 | "scripts": { 8 | "start": "tsc && node app", 9 | "typings": "typings", 10 | "postinstall": "typings install" 11 | }, 12 | "author": "Zia Khan", 13 | "license": "ISC", 14 | "dependencies": { 15 | "rxjs": "^5.0.0-beta.9" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /step00_helloworld_node/readme.md: -------------------------------------------------------------------------------- 1 | Prerequsite: 2 | 3 | https://github.com/panacloud/learn-typescript 4 | 5 | For Installation instructions: 6 | 7 | https://github.com/ReactiveX/RxJS 8 | 9 | This step covers the Preface code of the following book using RxJS 5 and TypeScript: 10 | 11 | http://www.amazon.com/Reactive-Programming-RxJS-Asynchronous-JavaScript-ebook/dp/B01ATYZTI4/ 12 | 13 | RxJS 5 Documentation: 14 | 15 | http://reactivex.io/rxjs/manual/overview.html 16 | 17 | If you dont have the book read: 18 | 19 | http://frontendgods.com/hello-rxjs-5/ 20 | 21 | Watch Video: 22 | 23 | https://www.youtube.com/watch?v=KTlay8cZdAk 24 | 25 | To run: 26 | 27 | npm install 28 | 29 | npm start 30 | 31 | -------------------------------------------------------------------------------- /step00_helloworld_node/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": false, 7 | "emitDecoratorMetadata": false, 8 | "experimentalDecorators": false, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | } 12 | } -------------------------------------------------------------------------------- /step00_helloworld_node/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalDependencies": { 3 | "core-js": "registry:dt/core-js#0.0.0+20160602141332", 4 | "node": "registry:dt/node#6.0.0+20160621231320" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /step00_helloworld_node/typings/globals/core-js/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts", 5 | "raw": "registry:dt/core-js#0.0.0+20160602141332", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step00_helloworld_node/typings/globals/node/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts", 5 | "raw": "registry:dt/node#6.0.0+20160621231320", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step00_helloworld_node/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /step01_helloworld_browser/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /step01_helloworld_browser/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // Available variables which can be used inside of strings. 2 | // ${workspaceRoot}: the root folder of the team 3 | // ${file}: the current opened file 4 | // ${fileBasename}: the current opened file's basename 5 | // ${fileDirname}: the current opened file's dirname 6 | // ${fileExtname}: the current opened file's extension 7 | // ${cwd}: the current working directory of the spawned process 8 | 9 | // A task runner that calls the Typescript compiler (tsc) and 10 | // Compiles a HelloWorld.ts program 11 | { 12 | "version": "0.1.0", 13 | 14 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 15 | "command": "tsc", 16 | 17 | // The command is a shell script 18 | "isShellCommand": true, 19 | 20 | // Show the output window only if unrecognized errors occur. 21 | "showOutput": "silent", 22 | 23 | // args is the HelloWorld program to compile. 24 | "args": ["app.ts"], 25 | 26 | // use the standard tsc problem matcher to find compile problems 27 | // in the output. 28 | "problemMatcher": "$tsc" 29 | } 30 | 31 | // A task runner that calls the Typescript compiler (tsc) and 32 | // compiles based on a tsconfig.json file that is present in 33 | // the root of the folder open in VSCode 34 | /* 35 | { 36 | "version": "0.1.0", 37 | 38 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 39 | "command": "tsc", 40 | 41 | // The command is a shell script 42 | "isShellCommand": true, 43 | 44 | // Show the output window only if unrecognized errors occur. 45 | "showOutput": "silent", 46 | 47 | // Tell the tsc compiler to use the tsconfig.json from the open folder. 48 | "args": ["-p", "."], 49 | 50 | // use the standard tsc problem matcher to find compile problems 51 | // in the output. 52 | "problemMatcher": "$tsc" 53 | } 54 | */ 55 | 56 | // A task runner configuration for gulp. Gulp provides a less task 57 | // which compiles less to css. 58 | /* 59 | { 60 | "version": "0.1.0", 61 | "command": "gulp", 62 | "isShellCommand": true, 63 | "tasks": [ 64 | { 65 | "taskName": "less", 66 | // Make this the default build command. 67 | "isBuildCommand": true, 68 | // Show the output window only if unrecognized errors occur. 69 | "showOutput": "silent", 70 | // Use the standard less compilation problem matcher. 71 | "problemMatcher": "$lessCompile" 72 | } 73 | ] 74 | } 75 | */ 76 | 77 | // Uncomment the following section to use jake to build a workspace 78 | // cloned from https://github.com/Microsoft/TypeScript.git 79 | /* 80 | { 81 | "version": "0.1.0", 82 | // Task runner is jake 83 | "command": "jake", 84 | // Need to be executed in shell / cmd 85 | "isShellCommand": true, 86 | "showOutput": "silent", 87 | "tasks": [ 88 | { 89 | // TS build command is local. 90 | "taskName": "local", 91 | // Make this the default build command. 92 | "isBuildCommand": true, 93 | // Show the output window only if unrecognized errors occur. 94 | "showOutput": "silent", 95 | // Use the redefined Typescript output problem matcher. 96 | "problemMatcher": [ 97 | "$tsc" 98 | ] 99 | } 100 | ] 101 | } 102 | */ 103 | 104 | // Uncomment the section below to use msbuild and generate problems 105 | // for csc, cpp, tsc and vb. The configuration assumes that msbuild 106 | // is available on the path and a solution file exists in the 107 | // workspace folder root. 108 | /* 109 | { 110 | "version": "0.1.0", 111 | "command": "msbuild", 112 | "args": [ 113 | // Ask msbuild to generate full paths for file names. 114 | "/property:GenerateFullPaths=true" 115 | ], 116 | "taskSelector": "/t:", 117 | "showOutput": "silent", 118 | "tasks": [ 119 | { 120 | "taskName": "build", 121 | // Show the output window only if unrecognized errors occur. 122 | "showOutput": "silent", 123 | // Use the standard MS compiler pattern to detect errors, warnings 124 | // and infos in the output. 125 | "problemMatcher": "$msCompile" 126 | } 127 | ] 128 | } 129 | */ 130 | 131 | // Uncomment the following section to use msbuild which compiles Typescript 132 | // and less files. 133 | /* 134 | { 135 | "version": "0.1.0", 136 | "command": "msbuild", 137 | "args": [ 138 | // Ask msbuild to generate full paths for file names. 139 | "/property:GenerateFullPaths=true" 140 | ], 141 | "taskSelector": "/t:", 142 | "showOutput": "silent", 143 | "tasks": [ 144 | { 145 | "taskName": "build", 146 | // Show the output window only if unrecognized errors occur. 147 | "showOutput": "silent", 148 | // Use the standard MS compiler pattern to detect errors, warnings 149 | // and infos in the output. 150 | "problemMatcher": [ 151 | "$msCompile", 152 | "$lessCompile" 153 | ] 154 | } 155 | ] 156 | } 157 | */ 158 | // A task runner example that defines a problemMatcher inline instead of using 159 | // a predfined one. 160 | /* 161 | { 162 | "version": "0.1.0", 163 | "command": "tsc", 164 | "isShellCommand": true, 165 | "args": ["HelloWorld.ts"], 166 | "showOutput": "silent", 167 | "problemMatcher": { 168 | // The problem is owned by the typescript language service. Ensure that the problems 169 | // are merged with problems produced by Visual Studio's language service. 170 | "owner": "typescript", 171 | // The file name for reported problems is relative to the current working directory. 172 | "fileLocation": ["relative", "${cwd}"], 173 | // The actual pattern to match problems in the output. 174 | "pattern": { 175 | // The regular expression. Matches HelloWorld.ts(2,10): error TS2339: Property 'logg' does not exist on type 'Console'. 176 | "regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$", 177 | // The match group that denotes the file containing the problem. 178 | "file": 1, 179 | // The match group that denotes the problem location. 180 | "location": 2, 181 | // The match group that denotes the problem's severity. Can be omitted. 182 | "severity": 3, 183 | // The match group that denotes the problem code. Can be omitted. 184 | "code": 4, 185 | // The match group that denotes the problem's message. 186 | "message": 5 187 | } 188 | } 189 | } 190 | */ -------------------------------------------------------------------------------- /step01_helloworld_browser/app/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Rx_1 = require('rxjs/Rx'); 3 | var button = document.getElementById('button'); 4 | var clicks = Rx_1.Observable.fromEvent(button, "click"); 5 | clicks.subscribe(function (x) { return alert("clicked"); }, function (err) { return alert("error"); }, function () { return alert('Completed'); }); 6 | //# sourceMappingURL=main.js.map -------------------------------------------------------------------------------- /step01_helloworld_browser/app/main.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"main.js","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":";AAAA,mBAAyB,SAAS,CAAC,CAAA;AAGnC,IAAI,MAAM,GAAG,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;AAE/C,IAAI,MAAM,GAAG,eAAU,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnD,MAAM,CAAC,SAAS,CACd,UAAC,CAAC,IAAK,OAAA,KAAK,CAAC,SAAS,CAAC,EAAhB,CAAgB,EACvB,UAAC,GAAG,IAAK,OAAA,KAAK,CAAC,OAAO,CAAC,EAAd,CAAc,EACvB,cAAM,OAAA,KAAK,CAAC,WAAW,CAAC,EAAlB,CAAkB,CACzB,CAAC"} -------------------------------------------------------------------------------- /step01_helloworld_browser/app/main.ts: -------------------------------------------------------------------------------- 1 | import {Observable} from 'rxjs/Rx'; 2 | 3 | 4 | var button = document.getElementById('button'); 5 | 6 | var clicks = Observable.fromEvent(button, "click"); 7 | 8 | clicks.subscribe( 9 | (x) => alert("clicked"), 10 | (err) => alert("error"), 11 | () => alert('Completed') 12 | ); 13 | 14 | -------------------------------------------------------------------------------- /step01_helloworld_browser/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | RxJS Sample in Browser 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /step01_helloworld_browser/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rxjs-in-browser", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ", 6 | "lite": "lite-server", 7 | "postinstall": "typings install", 8 | "tsc": "tsc", 9 | "tsc:w": "tsc -w", 10 | "typings": "typings" 11 | }, 12 | "license": "ISC", 13 | "dependencies": { 14 | "systemjs": "0.19.27", 15 | "core-js": "^2.4.0", 16 | "rxjs": "5.0.0-beta.9" 17 | }, 18 | "devDependencies": { 19 | "concurrently": "^2.0.0", 20 | "lite-server": "^2.2.0", 21 | "typescript": "^1.8.10", 22 | "typings":"^1.0.4" 23 | } 24 | } -------------------------------------------------------------------------------- /step01_helloworld_browser/readme.md: -------------------------------------------------------------------------------- 1 | Prerequsite: 2 | 3 | https://github.com/systemjs/systemjs 4 | 5 | For Installation and config instructions: 6 | 7 | http://www.metaltoad.com/blog/angular-2-http-observables 8 | 9 | This step covers the Preface code of the following book using RxJS 5 and TypeScript: 10 | 11 | http://www.amazon.com/Reactive-Programming-RxJS-Asynchronous-JavaScript-ebook/dp/B01ATYZTI4/ 12 | 13 | 14 | To run: 15 | 16 | npm install 17 | 18 | npm start 19 | -------------------------------------------------------------------------------- /step01_helloworld_browser/systemjs.config.js: -------------------------------------------------------------------------------- 1 | (function(global) { 2 | // map tells the System loader where to look for things 3 | var map = { 4 | 'app': 'app', // 'dist', 5 | 'rxjs': 'node_modules/rxjs' 6 | }; 7 | // packages tells the System loader how to load when no filename and/or no extension 8 | var packages = { 9 | 'app': { main: 'main.js', defaultExtension: 'js' }, 10 | 'rxjs': { defaultExtension: 'js' }, 11 | }; 12 | 13 | var config = { 14 | map: map, 15 | packages: packages 16 | }; 17 | System.config(config); 18 | })(this); 19 | -------------------------------------------------------------------------------- /step01_helloworld_browser/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": true, 7 | "emitDecoratorMetadata": true, 8 | "experimentalDecorators": true, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | } 12 | } -------------------------------------------------------------------------------- /step01_helloworld_browser/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalDependencies": { 3 | "core-js": "registry:dt/core-js#0.0.0+20160602141332", 4 | "node": "registry:dt/node#6.0.0+20160621231320" 5 | } 6 | } -------------------------------------------------------------------------------- /step01_helloworld_browser/typings/globals/core-js/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts", 5 | "raw": "registry:dt/core-js#0.0.0+20160602141332", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step01_helloworld_browser/typings/globals/node/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts", 5 | "raw": "registry:dt/node#6.0.0+20160621231320", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step01_helloworld_browser/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /step02_filter/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /step02_filter/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // Available variables which can be used inside of strings. 2 | // ${workspaceRoot}: the root folder of the team 3 | // ${file}: the current opened file 4 | // ${fileBasename}: the current opened file's basename 5 | // ${fileDirname}: the current opened file's dirname 6 | // ${fileExtname}: the current opened file's extension 7 | // ${cwd}: the current working directory of the spawned process 8 | 9 | // A task runner that calls the Typescript compiler (tsc) and 10 | // Compiles a HelloWorld.ts program 11 | { 12 | "version": "0.1.0", 13 | 14 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 15 | "command": "tsc", 16 | 17 | // The command is a shell script 18 | "isShellCommand": true, 19 | 20 | // Show the output window only if unrecognized errors occur. 21 | "showOutput": "silent", 22 | 23 | // args is the HelloWorld program to compile. 24 | "args": ["app.ts"], 25 | 26 | // use the standard tsc problem matcher to find compile problems 27 | // in the output. 28 | "problemMatcher": "$tsc" 29 | } 30 | 31 | // A task runner that calls the Typescript compiler (tsc) and 32 | // compiles based on a tsconfig.json file that is present in 33 | // the root of the folder open in VSCode 34 | /* 35 | { 36 | "version": "0.1.0", 37 | 38 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 39 | "command": "tsc", 40 | 41 | // The command is a shell script 42 | "isShellCommand": true, 43 | 44 | // Show the output window only if unrecognized errors occur. 45 | "showOutput": "silent", 46 | 47 | // Tell the tsc compiler to use the tsconfig.json from the open folder. 48 | "args": ["-p", "."], 49 | 50 | // use the standard tsc problem matcher to find compile problems 51 | // in the output. 52 | "problemMatcher": "$tsc" 53 | } 54 | */ 55 | 56 | // A task runner configuration for gulp. Gulp provides a less task 57 | // which compiles less to css. 58 | /* 59 | { 60 | "version": "0.1.0", 61 | "command": "gulp", 62 | "isShellCommand": true, 63 | "tasks": [ 64 | { 65 | "taskName": "less", 66 | // Make this the default build command. 67 | "isBuildCommand": true, 68 | // Show the output window only if unrecognized errors occur. 69 | "showOutput": "silent", 70 | // Use the standard less compilation problem matcher. 71 | "problemMatcher": "$lessCompile" 72 | } 73 | ] 74 | } 75 | */ 76 | 77 | // Uncomment the following section to use jake to build a workspace 78 | // cloned from https://github.com/Microsoft/TypeScript.git 79 | /* 80 | { 81 | "version": "0.1.0", 82 | // Task runner is jake 83 | "command": "jake", 84 | // Need to be executed in shell / cmd 85 | "isShellCommand": true, 86 | "showOutput": "silent", 87 | "tasks": [ 88 | { 89 | // TS build command is local. 90 | "taskName": "local", 91 | // Make this the default build command. 92 | "isBuildCommand": true, 93 | // Show the output window only if unrecognized errors occur. 94 | "showOutput": "silent", 95 | // Use the redefined Typescript output problem matcher. 96 | "problemMatcher": [ 97 | "$tsc" 98 | ] 99 | } 100 | ] 101 | } 102 | */ 103 | 104 | // Uncomment the section below to use msbuild and generate problems 105 | // for csc, cpp, tsc and vb. The configuration assumes that msbuild 106 | // is available on the path and a solution file exists in the 107 | // workspace folder root. 108 | /* 109 | { 110 | "version": "0.1.0", 111 | "command": "msbuild", 112 | "args": [ 113 | // Ask msbuild to generate full paths for file names. 114 | "/property:GenerateFullPaths=true" 115 | ], 116 | "taskSelector": "/t:", 117 | "showOutput": "silent", 118 | "tasks": [ 119 | { 120 | "taskName": "build", 121 | // Show the output window only if unrecognized errors occur. 122 | "showOutput": "silent", 123 | // Use the standard MS compiler pattern to detect errors, warnings 124 | // and infos in the output. 125 | "problemMatcher": "$msCompile" 126 | } 127 | ] 128 | } 129 | */ 130 | 131 | // Uncomment the following section to use msbuild which compiles Typescript 132 | // and less files. 133 | /* 134 | { 135 | "version": "0.1.0", 136 | "command": "msbuild", 137 | "args": [ 138 | // Ask msbuild to generate full paths for file names. 139 | "/property:GenerateFullPaths=true" 140 | ], 141 | "taskSelector": "/t:", 142 | "showOutput": "silent", 143 | "tasks": [ 144 | { 145 | "taskName": "build", 146 | // Show the output window only if unrecognized errors occur. 147 | "showOutput": "silent", 148 | // Use the standard MS compiler pattern to detect errors, warnings 149 | // and infos in the output. 150 | "problemMatcher": [ 151 | "$msCompile", 152 | "$lessCompile" 153 | ] 154 | } 155 | ] 156 | } 157 | */ 158 | // A task runner example that defines a problemMatcher inline instead of using 159 | // a predfined one. 160 | /* 161 | { 162 | "version": "0.1.0", 163 | "command": "tsc", 164 | "isShellCommand": true, 165 | "args": ["HelloWorld.ts"], 166 | "showOutput": "silent", 167 | "problemMatcher": { 168 | // The problem is owned by the typescript language service. Ensure that the problems 169 | // are merged with problems produced by Visual Studio's language service. 170 | "owner": "typescript", 171 | // The file name for reported problems is relative to the current working directory. 172 | "fileLocation": ["relative", "${cwd}"], 173 | // The actual pattern to match problems in the output. 174 | "pattern": { 175 | // The regular expression. Matches HelloWorld.ts(2,10): error TS2339: Property 'logg' does not exist on type 'Console'. 176 | "regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$", 177 | // The match group that denotes the file containing the problem. 178 | "file": 1, 179 | // The match group that denotes the problem location. 180 | "location": 2, 181 | // The match group that denotes the problem's severity. Can be omitted. 182 | "severity": 3, 183 | // The match group that denotes the problem code. Can be omitted. 184 | "code": 4, 185 | // The match group that denotes the problem's message. 186 | "message": 5 187 | } 188 | } 189 | } 190 | */ -------------------------------------------------------------------------------- /step02_filter/app/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Rx_1 = require('rxjs/Rx'); 3 | Rx_1.Observable.fromEvent(document, 'click') 4 | .filter(function (c) { 5 | return c.clientX > window.innerWidth / 2; 6 | }) 7 | .take(10) 8 | .subscribe(function (c) { 9 | console.log(c.clientX, c.clientY); 10 | }); 11 | //# sourceMappingURL=main.js.map -------------------------------------------------------------------------------- /step02_filter/app/main.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"main.js","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":";AAAA,mBAAyB,SAAS,CAAC,CAAA;AAEnC,eAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC;KACtC,MAAM,CAAC,UAAS,CAAa;IAC1B,MAAM,CAAC,CAAC,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC;AAC7C,CAAC,CAAC;KACD,IAAI,CAAC,EAAE,CAAC;KACR,SAAS,CAAC,UAAS,CAAa;IAC7B,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAA;AACrC,CAAC,CAAC,CAAA"} -------------------------------------------------------------------------------- /step02_filter/app/main.ts: -------------------------------------------------------------------------------- 1 | import {Observable} from 'rxjs/Rx'; 2 | 3 | Observable.fromEvent(document, 'click') 4 | .filter(function(c: MouseEvent) { 5 | return c.clientX > window.innerWidth / 2; 6 | }) 7 | .take(10) 8 | .subscribe(function(c: MouseEvent) { 9 | console.log(c.clientX, c.clientY) 10 | }) 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /step02_filter/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | RxJS Sample in Browser 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 21 | 22 | 23 | 24 |
Click in the right side of window, only first 10 will show on the console
25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /step02_filter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rxjs-in-browser", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ", 6 | "lite": "lite-server", 7 | "postinstall": "typings install", 8 | "tsc": "tsc", 9 | "tsc:w": "tsc -w", 10 | "typings": "typings" 11 | }, 12 | "license": "ISC", 13 | "dependencies": { 14 | "systemjs": "0.19.27", 15 | "core-js": "^2.4.0", 16 | "rxjs": "5.0.0-beta.9" 17 | }, 18 | "devDependencies": { 19 | "concurrently": "^2.0.0", 20 | "lite-server": "^2.2.0", 21 | "typescript": "^1.8.10", 22 | "typings":"^1.0.4" 23 | } 24 | } -------------------------------------------------------------------------------- /step02_filter/readme.md: -------------------------------------------------------------------------------- 1 | Prerequsite: 2 | 3 | https://github.com/systemjs/systemjs 4 | 5 | For Installation and config instructions: 6 | 7 | http://www.metaltoad.com/blog/angular-2-http-observables 8 | 9 | This step covers the Preface code of the following book using RxJS 5 and TypeScript: 10 | 11 | http://www.amazon.com/Reactive-Programming-RxJS-Asynchronous-JavaScript-ebook/dp/B01ATYZTI4/ 12 | 13 | 14 | To run: 15 | 16 | npm install 17 | 18 | npm start 19 | -------------------------------------------------------------------------------- /step02_filter/systemjs.config.js: -------------------------------------------------------------------------------- 1 | (function(global) { 2 | // map tells the System loader where to look for things 3 | var map = { 4 | 'app': 'app', // 'dist', 5 | 'rxjs': 'node_modules/rxjs' 6 | }; 7 | // packages tells the System loader how to load when no filename and/or no extension 8 | var packages = { 9 | 'app': { main: 'main.js', defaultExtension: 'js' }, 10 | 'rxjs': { defaultExtension: 'js' }, 11 | }; 12 | 13 | var config = { 14 | map: map, 15 | packages: packages 16 | }; 17 | System.config(config); 18 | })(this); 19 | -------------------------------------------------------------------------------- /step02_filter/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": true, 7 | "emitDecoratorMetadata": true, 8 | "experimentalDecorators": true, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | } 12 | } -------------------------------------------------------------------------------- /step02_filter/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalDependencies": { 3 | "core-js": "registry:dt/core-js#0.0.0+20160602141332", 4 | "node": "registry:dt/node#6.0.0+20160621231320" 5 | } 6 | } -------------------------------------------------------------------------------- /step02_filter/typings/globals/core-js/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts", 5 | "raw": "registry:dt/core-js#0.0.0+20160602141332", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step02_filter/typings/globals/node/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts", 5 | "raw": "registry:dt/node#6.0.0+20160621231320", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step02_filter/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /step03_create/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /step03_create/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // Available variables which can be used inside of strings. 2 | // ${workspaceRoot}: the root folder of the team 3 | // ${file}: the current opened file 4 | // ${fileBasename}: the current opened file's basename 5 | // ${fileDirname}: the current opened file's dirname 6 | // ${fileExtname}: the current opened file's extension 7 | // ${cwd}: the current working directory of the spawned process 8 | 9 | // A task runner that calls the Typescript compiler (tsc) and 10 | // Compiles a HelloWorld.ts program 11 | { 12 | "version": "0.1.0", 13 | 14 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 15 | "command": "tsc", 16 | 17 | // The command is a shell script 18 | "isShellCommand": true, 19 | 20 | // Show the output window only if unrecognized errors occur. 21 | "showOutput": "silent", 22 | 23 | // args is the HelloWorld program to compile. 24 | "args": ["app.ts"], 25 | 26 | // use the standard tsc problem matcher to find compile problems 27 | // in the output. 28 | "problemMatcher": "$tsc" 29 | } 30 | 31 | // A task runner that calls the Typescript compiler (tsc) and 32 | // compiles based on a tsconfig.json file that is present in 33 | // the root of the folder open in VSCode 34 | /* 35 | { 36 | "version": "0.1.0", 37 | 38 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 39 | "command": "tsc", 40 | 41 | // The command is a shell script 42 | "isShellCommand": true, 43 | 44 | // Show the output window only if unrecognized errors occur. 45 | "showOutput": "silent", 46 | 47 | // Tell the tsc compiler to use the tsconfig.json from the open folder. 48 | "args": ["-p", "."], 49 | 50 | // use the standard tsc problem matcher to find compile problems 51 | // in the output. 52 | "problemMatcher": "$tsc" 53 | } 54 | */ 55 | 56 | // A task runner configuration for gulp. Gulp provides a less task 57 | // which compiles less to css. 58 | /* 59 | { 60 | "version": "0.1.0", 61 | "command": "gulp", 62 | "isShellCommand": true, 63 | "tasks": [ 64 | { 65 | "taskName": "less", 66 | // Make this the default build command. 67 | "isBuildCommand": true, 68 | // Show the output window only if unrecognized errors occur. 69 | "showOutput": "silent", 70 | // Use the standard less compilation problem matcher. 71 | "problemMatcher": "$lessCompile" 72 | } 73 | ] 74 | } 75 | */ 76 | 77 | // Uncomment the following section to use jake to build a workspace 78 | // cloned from https://github.com/Microsoft/TypeScript.git 79 | /* 80 | { 81 | "version": "0.1.0", 82 | // Task runner is jake 83 | "command": "jake", 84 | // Need to be executed in shell / cmd 85 | "isShellCommand": true, 86 | "showOutput": "silent", 87 | "tasks": [ 88 | { 89 | // TS build command is local. 90 | "taskName": "local", 91 | // Make this the default build command. 92 | "isBuildCommand": true, 93 | // Show the output window only if unrecognized errors occur. 94 | "showOutput": "silent", 95 | // Use the redefined Typescript output problem matcher. 96 | "problemMatcher": [ 97 | "$tsc" 98 | ] 99 | } 100 | ] 101 | } 102 | */ 103 | 104 | // Uncomment the section below to use msbuild and generate problems 105 | // for csc, cpp, tsc and vb. The configuration assumes that msbuild 106 | // is available on the path and a solution file exists in the 107 | // workspace folder root. 108 | /* 109 | { 110 | "version": "0.1.0", 111 | "command": "msbuild", 112 | "args": [ 113 | // Ask msbuild to generate full paths for file names. 114 | "/property:GenerateFullPaths=true" 115 | ], 116 | "taskSelector": "/t:", 117 | "showOutput": "silent", 118 | "tasks": [ 119 | { 120 | "taskName": "build", 121 | // Show the output window only if unrecognized errors occur. 122 | "showOutput": "silent", 123 | // Use the standard MS compiler pattern to detect errors, warnings 124 | // and infos in the output. 125 | "problemMatcher": "$msCompile" 126 | } 127 | ] 128 | } 129 | */ 130 | 131 | // Uncomment the following section to use msbuild which compiles Typescript 132 | // and less files. 133 | /* 134 | { 135 | "version": "0.1.0", 136 | "command": "msbuild", 137 | "args": [ 138 | // Ask msbuild to generate full paths for file names. 139 | "/property:GenerateFullPaths=true" 140 | ], 141 | "taskSelector": "/t:", 142 | "showOutput": "silent", 143 | "tasks": [ 144 | { 145 | "taskName": "build", 146 | // Show the output window only if unrecognized errors occur. 147 | "showOutput": "silent", 148 | // Use the standard MS compiler pattern to detect errors, warnings 149 | // and infos in the output. 150 | "problemMatcher": [ 151 | "$msCompile", 152 | "$lessCompile" 153 | ] 154 | } 155 | ] 156 | } 157 | */ 158 | // A task runner example that defines a problemMatcher inline instead of using 159 | // a predfined one. 160 | /* 161 | { 162 | "version": "0.1.0", 163 | "command": "tsc", 164 | "isShellCommand": true, 165 | "args": ["HelloWorld.ts"], 166 | "showOutput": "silent", 167 | "problemMatcher": { 168 | // The problem is owned by the typescript language service. Ensure that the problems 169 | // are merged with problems produced by Visual Studio's language service. 170 | "owner": "typescript", 171 | // The file name for reported problems is relative to the current working directory. 172 | "fileLocation": ["relative", "${cwd}"], 173 | // The actual pattern to match problems in the output. 174 | "pattern": { 175 | // The regular expression. Matches HelloWorld.ts(2,10): error TS2339: Property 'logg' does not exist on type 'Console'. 176 | "regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$", 177 | // The match group that denotes the file containing the problem. 178 | "file": 1, 179 | // The match group that denotes the problem location. 180 | "location": 2, 181 | // The match group that denotes the problem's severity. Can be omitted. 182 | "severity": 3, 183 | // The match group that denotes the problem code. Can be omitted. 184 | "code": 4, 185 | // The match group that denotes the problem's message. 186 | "message": 5 187 | } 188 | } 189 | } 190 | */ -------------------------------------------------------------------------------- /step03_create/app.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Rx = require('rxjs/Rx'); 3 | /* 4 | https://github.com/ReactiveX/RxJS/blob/master/MIGRATION.md 5 | */ 6 | var observable = Rx.Observable.create(function (observer) { 7 | observer.next('Simon'); 8 | observer.next('Jen'); 9 | observer.next('Sergi'); 10 | observer.complete(); // We are done 11 | }); 12 | observable.subscribe(function next(x) { console.log('Next: ' + x); }, function error(err) { console.log('Error: ' + err); }, function complete() { console.log('Completed'); }); 13 | -------------------------------------------------------------------------------- /step03_create/app.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":";AAAA,IAAO,EAAE,WAAW,SAAS,CAAC,CAAC;AAE/B;;EAEE;AACF,IAAI,UAAU,GAA2B,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,UAAS,QAA6B;IAChG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,cAAc;AACvC,CAAC,CAAC,CAAC;AAGH,UAAU,CAAC,SAAS,CAChB,cAAc,CAAS,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EACvD,eAAe,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EACrD,sBAAsB,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CACpD,CAAC"} -------------------------------------------------------------------------------- /step03_create/app.ts: -------------------------------------------------------------------------------- 1 | import Rx = require('rxjs/Rx'); 2 | 3 | /* 4 | https://github.com/ReactiveX/RxJS/blob/master/MIGRATION.md 5 | */ 6 | var observable : Rx.Observable = Rx.Observable.create(function(observer: Rx.Observer) { 7 | observer.next('Simon'); 8 | observer.next('Jen'); 9 | observer.next('Sergi'); 10 | observer.complete(); // We are done 11 | }); 12 | 13 | 14 | observable.subscribe( 15 | function next(x: String) { console.log('Next: ' + x); }, 16 | function error(err) { console.log('Error: ' + err); }, 17 | function complete() { console.log('Completed'); } 18 | ); 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /step03_create/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "step00_helloworld", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.ts", 6 | "devDependencies": {}, 7 | "scripts": { 8 | "start": "tsc && node app", 9 | "typings": "typings", 10 | "postinstall": "typings install" 11 | }, 12 | "author": "Zia Khan", 13 | "license": "ISC", 14 | "dependencies": { 15 | "rxjs": "^5.0.0-beta.9" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /step03_create/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This step covers the chapter 1 code on page 10-11 of the following book using RxJS 5 and TypeScript: 4 | 5 | http://www.amazon.com/Reactive-Programming-RxJS-Asynchronous-JavaScript-ebook/dp/B01ATYZTI4/ 6 | 7 | In RxJS 5 the syntax has changed a bit: 8 | 9 | https://github.com/ReactiveX/RxJS/blob/master/MIGRATION.md 10 | 11 | To run: 12 | 13 | npm install 14 | 15 | npm start 16 | 17 | -------------------------------------------------------------------------------- /step03_create/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": false, 7 | "emitDecoratorMetadata": false, 8 | "experimentalDecorators": false, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | } 12 | } -------------------------------------------------------------------------------- /step03_create/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalDependencies": { 3 | "core-js": "registry:dt/core-js#0.0.0+20160602141332", 4 | "node": "registry:dt/node#6.0.0+20160621231320" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /step03_create/typings/globals/core-js/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts", 5 | "raw": "registry:dt/core-js#0.0.0+20160602141332", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step03_create/typings/globals/node/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts", 5 | "raw": "registry:dt/node#6.0.0+20160621231320", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step03_create/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /step04_ajax/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /step04_ajax/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // Available variables which can be used inside of strings. 2 | // ${workspaceRoot}: the root folder of the team 3 | // ${file}: the current opened file 4 | // ${fileBasename}: the current opened file's basename 5 | // ${fileDirname}: the current opened file's dirname 6 | // ${fileExtname}: the current opened file's extension 7 | // ${cwd}: the current working directory of the spawned process 8 | 9 | // A task runner that calls the Typescript compiler (tsc) and 10 | // Compiles a HelloWorld.ts program 11 | { 12 | "version": "0.1.0", 13 | 14 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 15 | "command": "tsc", 16 | 17 | // The command is a shell script 18 | "isShellCommand": true, 19 | 20 | // Show the output window only if unrecognized errors occur. 21 | "showOutput": "silent", 22 | 23 | // args is the HelloWorld program to compile. 24 | "args": ["app.ts"], 25 | 26 | // use the standard tsc problem matcher to find compile problems 27 | // in the output. 28 | "problemMatcher": "$tsc" 29 | } 30 | 31 | // A task runner that calls the Typescript compiler (tsc) and 32 | // compiles based on a tsconfig.json file that is present in 33 | // the root of the folder open in VSCode 34 | /* 35 | { 36 | "version": "0.1.0", 37 | 38 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 39 | "command": "tsc", 40 | 41 | // The command is a shell script 42 | "isShellCommand": true, 43 | 44 | // Show the output window only if unrecognized errors occur. 45 | "showOutput": "silent", 46 | 47 | // Tell the tsc compiler to use the tsconfig.json from the open folder. 48 | "args": ["-p", "."], 49 | 50 | // use the standard tsc problem matcher to find compile problems 51 | // in the output. 52 | "problemMatcher": "$tsc" 53 | } 54 | */ 55 | 56 | // A task runner configuration for gulp. Gulp provides a less task 57 | // which compiles less to css. 58 | /* 59 | { 60 | "version": "0.1.0", 61 | "command": "gulp", 62 | "isShellCommand": true, 63 | "tasks": [ 64 | { 65 | "taskName": "less", 66 | // Make this the default build command. 67 | "isBuildCommand": true, 68 | // Show the output window only if unrecognized errors occur. 69 | "showOutput": "silent", 70 | // Use the standard less compilation problem matcher. 71 | "problemMatcher": "$lessCompile" 72 | } 73 | ] 74 | } 75 | */ 76 | 77 | // Uncomment the following section to use jake to build a workspace 78 | // cloned from https://github.com/Microsoft/TypeScript.git 79 | /* 80 | { 81 | "version": "0.1.0", 82 | // Task runner is jake 83 | "command": "jake", 84 | // Need to be executed in shell / cmd 85 | "isShellCommand": true, 86 | "showOutput": "silent", 87 | "tasks": [ 88 | { 89 | // TS build command is local. 90 | "taskName": "local", 91 | // Make this the default build command. 92 | "isBuildCommand": true, 93 | // Show the output window only if unrecognized errors occur. 94 | "showOutput": "silent", 95 | // Use the redefined Typescript output problem matcher. 96 | "problemMatcher": [ 97 | "$tsc" 98 | ] 99 | } 100 | ] 101 | } 102 | */ 103 | 104 | // Uncomment the section below to use msbuild and generate problems 105 | // for csc, cpp, tsc and vb. The configuration assumes that msbuild 106 | // is available on the path and a solution file exists in the 107 | // workspace folder root. 108 | /* 109 | { 110 | "version": "0.1.0", 111 | "command": "msbuild", 112 | "args": [ 113 | // Ask msbuild to generate full paths for file names. 114 | "/property:GenerateFullPaths=true" 115 | ], 116 | "taskSelector": "/t:", 117 | "showOutput": "silent", 118 | "tasks": [ 119 | { 120 | "taskName": "build", 121 | // Show the output window only if unrecognized errors occur. 122 | "showOutput": "silent", 123 | // Use the standard MS compiler pattern to detect errors, warnings 124 | // and infos in the output. 125 | "problemMatcher": "$msCompile" 126 | } 127 | ] 128 | } 129 | */ 130 | 131 | // Uncomment the following section to use msbuild which compiles Typescript 132 | // and less files. 133 | /* 134 | { 135 | "version": "0.1.0", 136 | "command": "msbuild", 137 | "args": [ 138 | // Ask msbuild to generate full paths for file names. 139 | "/property:GenerateFullPaths=true" 140 | ], 141 | "taskSelector": "/t:", 142 | "showOutput": "silent", 143 | "tasks": [ 144 | { 145 | "taskName": "build", 146 | // Show the output window only if unrecognized errors occur. 147 | "showOutput": "silent", 148 | // Use the standard MS compiler pattern to detect errors, warnings 149 | // and infos in the output. 150 | "problemMatcher": [ 151 | "$msCompile", 152 | "$lessCompile" 153 | ] 154 | } 155 | ] 156 | } 157 | */ 158 | // A task runner example that defines a problemMatcher inline instead of using 159 | // a predfined one. 160 | /* 161 | { 162 | "version": "0.1.0", 163 | "command": "tsc", 164 | "isShellCommand": true, 165 | "args": ["HelloWorld.ts"], 166 | "showOutput": "silent", 167 | "problemMatcher": { 168 | // The problem is owned by the typescript language service. Ensure that the problems 169 | // are merged with problems produced by Visual Studio's language service. 170 | "owner": "typescript", 171 | // The file name for reported problems is relative to the current working directory. 172 | "fileLocation": ["relative", "${cwd}"], 173 | // The actual pattern to match problems in the output. 174 | "pattern": { 175 | // The regular expression. Matches HelloWorld.ts(2,10): error TS2339: Property 'logg' does not exist on type 'Console'. 176 | "regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$", 177 | // The match group that denotes the file containing the problem. 178 | "file": 1, 179 | // The match group that denotes the problem location. 180 | "location": 2, 181 | // The match group that denotes the problem's severity. Can be omitted. 182 | "severity": 3, 183 | // The match group that denotes the problem code. Can be omitted. 184 | "code": 4, 185 | // The match group that denotes the problem's message. 186 | "message": 5 187 | } 188 | } 189 | } 190 | */ -------------------------------------------------------------------------------- /step04_ajax/app/contents.json: -------------------------------------------------------------------------------- 1 | {"employees":[ 2 | {"firstName":"John", "lastName":"Doe"}, 3 | {"firstName":"Anna", "lastName":"Smith"}, 4 | {"firstName":"Peter", "lastName":"Jones"} 5 | ]} -------------------------------------------------------------------------------- /step04_ajax/app/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Rx_1 = require('rxjs/Rx'); 3 | function get(url) { 4 | return Rx_1.Observable.create(function (observer) { 5 | // Make a traditional Ajax request 6 | var req = new XMLHttpRequest(); 7 | req.open('GET', url); 8 | req.onload = function () { 9 | if (req.status == 200) { 10 | // If the status is 200, meaning there have been no problems, 11 | // Yield the result to listeners and complete the sequence 12 | observer.next(req.response); 13 | observer.complete(); 14 | } 15 | else { 16 | // Otherwise, signal to listeners that there has been an error 17 | observer.error(new Error(req.statusText)); 18 | } 19 | }; 20 | req.onerror = function () { 21 | observer.error(new Error("Unknown Error")); 22 | }; 23 | req.send(); 24 | }); 25 | } 26 | // Create an Ajax Observable 27 | var test = get('/app/contents.json'); 28 | test.subscribe(function next(x) { console.log('Result: ' + x); }, function error(err) { console.log('Error: ' + err); }, function complete() { console.log('Completed'); }); 29 | //# sourceMappingURL=main.js.map -------------------------------------------------------------------------------- /step04_ajax/app/main.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"main.js","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":";AAAA,mBAAmC,SAAS,CAAC,CAAA;AAE7C,aAAa,GAAG;IACZ,MAAM,CAAC,eAAU,CAAC,MAAM,CAAC,UAAS,QAA0B;QAC5D,kCAAkC;QAClC,IAAI,GAAG,GAAG,IAAI,cAAc,EAAE,CAAC;QAC/B,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACrB,GAAG,CAAC,MAAM,GAAG;YACT,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC;gBACxB,6DAA6D;gBAC7D,0DAA0D;gBACtD,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAC5B,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACxB,CAAC;YACD,IAAI,CAAC,CAAC;gBACN,8DAA8D;gBAC1D,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;YAC9C,CAAC;QACL,CAAC,CAAC;QACF,GAAG,CAAC,OAAO,GAAG;YACV,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;QAC/C,CAAC,CAAC;QACF,GAAG,CAAC,IAAI,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;AACH,CAAC;AACD,4BAA4B;AAC5B,IAAI,IAAI,GAAG,GAAG,CAAC,oBAAoB,CAAC,CAAC;AACrC,IAAI,CAAC,SAAS,CACV,cAAc,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EACjD,eAAe,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EACrD,sBAAsB,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CACpD,CAAC"} -------------------------------------------------------------------------------- /step04_ajax/app/main.ts: -------------------------------------------------------------------------------- 1 | import {Observable, Observer} from 'rxjs/Rx'; 2 | 3 | function get(url) { 4 | return Observable.create(function(observer: Observer) { 5 | // Make a traditional Ajax request 6 | var req = new XMLHttpRequest(); 7 | req.open('GET', url); 8 | req.onload = function() { 9 | if (req.status == 200) { 10 | // If the status is 200, meaning there have been no problems, 11 | // Yield the result to listeners and complete the sequence 12 | observer.next(req.response); 13 | observer.complete(); 14 | } 15 | else { 16 | // Otherwise, signal to listeners that there has been an error 17 | observer.error(new Error(req.statusText)); 18 | } 19 | }; 20 | req.onerror = function() { 21 | observer.error(new Error("Unknown Error")); 22 | }; 23 | req.send(); 24 | }); 25 | } 26 | // Create an Ajax Observable 27 | var test = get('/app/contents.json'); 28 | test.subscribe( 29 | function next(x) { console.log('Result: ' + x); }, 30 | function error(err) { console.log('Error: ' + err); }, 31 | function complete() { console.log('Completed'); } 32 | ); 33 | 34 | -------------------------------------------------------------------------------- /step04_ajax/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | RxJS Sample in Browser 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /step04_ajax/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rxjs-in-browser", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ", 6 | "lite": "lite-server", 7 | "postinstall": "typings install", 8 | "tsc": "tsc", 9 | "tsc:w": "tsc -w", 10 | "typings": "typings" 11 | }, 12 | "license": "ISC", 13 | "dependencies": { 14 | "systemjs": "0.19.27", 15 | "core-js": "^2.4.0", 16 | "rxjs": "5.0.0-beta.9" 17 | }, 18 | "devDependencies": { 19 | "concurrently": "^2.0.0", 20 | "lite-server": "^2.2.0", 21 | "typescript": "^1.8.10", 22 | "typings":"^1.0.4" 23 | } 24 | } -------------------------------------------------------------------------------- /step04_ajax/readme.md: -------------------------------------------------------------------------------- 1 | Prerequsite: 2 | 3 | https://github.com/systemjs/systemjs 4 | 5 | For Installation and config instructions: 6 | 7 | http://www.metaltoad.com/blog/angular-2-http-observables 8 | 9 | This step covers the Preface code of the following book using RxJS 5 and TypeScript: 10 | 11 | http://www.amazon.com/Reactive-Programming-RxJS-Asynchronous-JavaScript-ebook/dp/B01ATYZTI4/ 12 | 13 | 14 | To run: 15 | 16 | npm install 17 | 18 | npm start 19 | -------------------------------------------------------------------------------- /step04_ajax/systemjs.config.js: -------------------------------------------------------------------------------- 1 | (function(global) { 2 | // map tells the System loader where to look for things 3 | var map = { 4 | 'app': 'app', // 'dist', 5 | 'rxjs': 'node_modules/rxjs' 6 | }; 7 | // packages tells the System loader how to load when no filename and/or no extension 8 | var packages = { 9 | 'app': { main: 'main.js', defaultExtension: 'js' }, 10 | 'rxjs': { defaultExtension: 'js' }, 11 | }; 12 | 13 | var config = { 14 | map: map, 15 | packages: packages 16 | }; 17 | System.config(config); 18 | })(this); 19 | -------------------------------------------------------------------------------- /step04_ajax/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": true, 7 | "emitDecoratorMetadata": true, 8 | "experimentalDecorators": true, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | } 12 | } -------------------------------------------------------------------------------- /step04_ajax/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalDependencies": { 3 | "core-js": "registry:dt/core-js#0.0.0+20160602141332", 4 | "node": "registry:dt/node#6.0.0+20160621231320" 5 | } 6 | } -------------------------------------------------------------------------------- /step04_ajax/typings/globals/core-js/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts", 5 | "raw": "registry:dt/core-js#0.0.0+20160602141332", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step04_ajax/typings/globals/node/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts", 5 | "raw": "registry:dt/node#6.0.0+20160621231320", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step04_ajax/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /step05_create_from_array/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /step05_create_from_array/app.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Rx = require('rxjs/Rx'); 3 | Rx.Observable 4 | .from(['Adrià', 'Jen', 'Sergi']) 5 | .subscribe(function (x) { console.log('Next: ' + x); }, function (err) { console.log('Error:', err); }, function () { console.log('Completed'); }); 6 | -------------------------------------------------------------------------------- /step05_create_from_array/app.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":";AAAA,IAAO,EAAE,WAAW,SAAS,CAAC,CAAC;AAE/B;;EAEE;AACF,EAAE,CAAC,UAAU;KACZ,IAAI,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;KAC/B,SAAS,CACN,UAAS,CAAS,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAClD,UAAS,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAC7C,cAAa,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAC3C,CAAC"} -------------------------------------------------------------------------------- /step05_create_from_array/app.ts: -------------------------------------------------------------------------------- 1 | import Rx = require('rxjs/Rx'); 2 | 3 | 4 | Rx.Observable 5 | .from(['Adrià', 'Jen', 'Sergi']) 6 | .subscribe( 7 | function(x: String) { console.log('Next: ' + x); }, 8 | function(err) { console.log('Error:', err); }, 9 | function() { console.log('Completed'); } 10 | ); 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /step05_create_from_array/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "step00_helloworld", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.ts", 6 | "devDependencies": {}, 7 | "scripts": { 8 | "start": "tsc && node app", 9 | "typings": "typings", 10 | "postinstall": "typings install" 11 | }, 12 | "author": "Zia Khan", 13 | "license": "ISC", 14 | "dependencies": { 15 | "rxjs": "^5.0.0-beta.9" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /step05_create_from_array/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This step covers the chapter 1 code on page 13 of the following book using RxJS 5 and TypeScript: 4 | 5 | http://www.amazon.com/Reactive-Programming-RxJS-Asynchronous-JavaScript-ebook/dp/B01ATYZTI4/ 6 | 7 | 8 | To run: 9 | 10 | npm install 11 | 12 | npm start 13 | 14 | -------------------------------------------------------------------------------- /step05_create_from_array/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": false, 7 | "emitDecoratorMetadata": false, 8 | "experimentalDecorators": false, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | } 12 | } -------------------------------------------------------------------------------- /step05_create_from_array/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalDependencies": { 3 | "core-js": "registry:dt/core-js#0.0.0+20160602141332", 4 | "node": "registry:dt/node#6.0.0+20160621231320" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /step05_create_from_array/typings/globals/core-js/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts", 5 | "raw": "registry:dt/core-js#0.0.0+20160602141332", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step05_create_from_array/typings/globals/node/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts", 5 | "raw": "registry:dt/node#6.0.0+20160621231320", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step05_create_from_array/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /step06_merge/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /step06_merge/app.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Rx = require('rxjs/Rx'); 3 | var a = Rx.Observable.interval(200).map(function (i) { 4 | return 'A' + i; 5 | }); 6 | var b = Rx.Observable.interval(100).map(function (i) { 7 | return 'B' + i; 8 | }); 9 | var m = Rx.Observable.merge(a, b); 10 | m.subscribe(function (x) { 11 | console.log(x); 12 | }); 13 | -------------------------------------------------------------------------------- /step06_merge/app.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":";AAAA,IAAO,EAAE,WAAW,SAAS,CAAC,CAAC;AAG/B,IAAI,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAS,CAAS;IACtD,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC;AACH,IAAI,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAS,CAAS;IACtD,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC;AACH,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,UAAS,CAAS;IAClD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /step06_merge/app.ts: -------------------------------------------------------------------------------- 1 | import Rx = require('rxjs/Rx'); 2 | 3 | 4 | var a = Rx.Observable.interval(200).map(function(i: number) { 5 | return 'A' + i; 6 | }); 7 | var b = Rx.Observable.interval(100).map(function(i: number) { 8 | return 'B' + i; 9 | }); 10 | 11 | var m = Rx.Observable.merge(a, b); 12 | 13 | m.subscribe(function(x: string) { 14 | console.log(x); 15 | }); 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /step06_merge/npm-debug.log: -------------------------------------------------------------------------------- 1 | 0 info it worked if it ends with ok 2 | 1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ] 3 | 2 info using npm@3.6.0 4 | 3 info using node@v5.6.0 5 | 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 6 | 5 info lifecycle step00_helloworld@1.0.0~prestart: step00_helloworld@1.0.0 7 | 6 silly lifecycle step00_helloworld@1.0.0~prestart: no script for prestart, continuing 8 | 7 info lifecycle step00_helloworld@1.0.0~start: step00_helloworld@1.0.0 9 | 8 verbose lifecycle step00_helloworld@1.0.0~start: unsafe-perm in lifecycle true 10 | 9 verbose lifecycle step00_helloworld@1.0.0~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/ZiaKhan/learn-typed-rxjs/step06_merge/node_modules/.bin:/Users/ZiaKhan/anaconda/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/users/ZiaKhan/.cargo/bin:/users/ZiaKhan/apache-ant-1.9.4/bin:/users/ZiaKhan/Library/Android/sdk/tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin 11 | 10 verbose lifecycle step00_helloworld@1.0.0~start: CWD: /Users/ZiaKhan/learn-typed-rxjs/step06_merge 12 | 11 silly lifecycle step00_helloworld@1.0.0~start: Args: [ '-c', 'tsc && node app' ] 13 | 12 silly lifecycle step00_helloworld@1.0.0~start: Returned: code: 2 signal: null 14 | 13 info lifecycle step00_helloworld@1.0.0~start: Failed to exec start script 15 | 14 verbose stack Error: step00_helloworld@1.0.0 start: `tsc && node app` 16 | 14 verbose stack Exit status 2 17 | 14 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:232:16) 18 | 14 verbose stack at emitTwo (events.js:100:13) 19 | 14 verbose stack at EventEmitter.emit (events.js:185:7) 20 | 14 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14) 21 | 14 verbose stack at emitTwo (events.js:100:13) 22 | 14 verbose stack at ChildProcess.emit (events.js:185:7) 23 | 14 verbose stack at maybeClose (internal/child_process.js:827:16) 24 | 14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5) 25 | 15 verbose pkgid step00_helloworld@1.0.0 26 | 16 verbose cwd /Users/ZiaKhan/learn-typed-rxjs/step06_merge 27 | 17 error Darwin 15.5.0 28 | 18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" 29 | 19 error node v5.6.0 30 | 20 error npm v3.6.0 31 | 21 error code ELIFECYCLE 32 | 22 error step00_helloworld@1.0.0 start: `tsc && node app` 33 | 22 error Exit status 2 34 | 23 error Failed at the step00_helloworld@1.0.0 start script 'tsc && node app'. 35 | 23 error Make sure you have the latest version of node.js and npm installed. 36 | 23 error If you do, this is most likely a problem with the step00_helloworld package, 37 | 23 error not with npm itself. 38 | 23 error Tell the author that this fails on your system: 39 | 23 error tsc && node app 40 | 23 error You can get information on how to open an issue for this project with: 41 | 23 error npm bugs step00_helloworld 42 | 23 error Or if that isn't available, you can get their info via: 43 | 23 error npm owner ls step00_helloworld 44 | 23 error There is likely additional logging output above. 45 | 24 verbose exit [ 1, true ] 46 | -------------------------------------------------------------------------------- /step06_merge/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "step00_helloworld", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.ts", 6 | "devDependencies": {}, 7 | "scripts": { 8 | "start": "tsc && node app", 9 | "typings": "typings", 10 | "postinstall": "typings install" 11 | }, 12 | "author": "Zia Khan", 13 | "license": "ISC", 14 | "dependencies": { 15 | "rxjs": "^5.0.0-beta.9" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /step06_merge/readme.md: -------------------------------------------------------------------------------- 1 | This step covers the chapter 2 code on page 18 of the following book using RxJS 5 and TypeScript: 2 | 3 | http://www.amazon.com/Reactive-Programming-RxJS-Asynchronous-JavaScript-ebook/dp/B01ATYZTI4/ 4 | 5 | 6 | To run: 7 | 8 | npm install 9 | 10 | npm start 11 | 12 | -------------------------------------------------------------------------------- /step06_merge/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": false, 7 | "emitDecoratorMetadata": false, 8 | "experimentalDecorators": false, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | } 12 | } -------------------------------------------------------------------------------- /step06_merge/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalDependencies": { 3 | "core-js": "registry:dt/core-js#0.0.0+20160602141332", 4 | "node": "registry:dt/node#6.0.0+20160621231320" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /step06_merge/typings/globals/core-js/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts", 5 | "raw": "registry:dt/core-js#0.0.0+20160602141332", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step06_merge/typings/globals/node/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts", 5 | "raw": "registry:dt/node#6.0.0+20160621231320", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step06_merge/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /step07_map/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /step07_map/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Launch", 6 | "type": "node", 7 | "request": "launch", 8 | "program": "${workspaceRoot}app.ts", 9 | "stopOnEntry": false, 10 | "args": [], 11 | "cwd": "${workspaceRoot}", 12 | "runtimeExecutable": null, 13 | "runtimeArgs": [ 14 | "--nolazy" 15 | ], 16 | "env": { 17 | "NODE_ENV": "development" 18 | }, 19 | "externalConsole": false, 20 | "sourceMaps": false, 21 | "outDir": null 22 | }, 23 | { 24 | "name": "Attach", 25 | "type": "node", 26 | "request": "attach", 27 | "port": 5858, 28 | "sourceMaps": false, 29 | "outDir": null, 30 | "localRoot": "${workspaceRoot}", 31 | "remoteRoot": null 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /step07_map/app.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Rx = require('rxjs/Rx'); 3 | var src = Rx.Observable.range(1, 5); 4 | var upper = src.map(function (val) { 5 | return val * 2; 6 | }); 7 | upper.subscribe(function (val) { 8 | console.log(val); 9 | }); 10 | -------------------------------------------------------------------------------- /step07_map/app.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":";AAAA,IAAO,EAAE,WAAW,SAAS,CAAC,CAAC;AAE/B,IAAI,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEpC,IAAI,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,UAAS,GAAW;IACpC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC;AAEH,KAAK,CAAC,SAAS,CAAC,UAAS,GAAG;IACxB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACpB,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /step07_map/app.ts: -------------------------------------------------------------------------------- 1 | import Rx = require('rxjs/Rx'); 2 | 3 | var src = Rx.Observable.range(1, 5); 4 | 5 | var upper = src.map(function(val: number) { 6 | return val * 2; 7 | }); 8 | 9 | upper.subscribe(function(val) { 10 | console.log(val) 11 | }); 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /step07_map/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "step00_helloworld", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.ts", 6 | "devDependencies": {}, 7 | "scripts": { 8 | "start": "tsc && node app", 9 | "typings": "typings", 10 | "postinstall": "typings install" 11 | }, 12 | "author": "Zia Khan", 13 | "license": "ISC", 14 | "dependencies": { 15 | "rxjs": "^5.0.0-beta.9" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /step07_map/readme.md: -------------------------------------------------------------------------------- 1 | This step covers the chapter 2 code on page 19 of the following book using RxJS 5 and TypeScript: 2 | 3 | http://www.amazon.com/Reactive-Programming-RxJS-Asynchronous-JavaScript-ebook/dp/B01ATYZTI4/ 4 | 5 | 6 | To run: 7 | 8 | npm install 9 | 10 | npm start 11 | 12 | -------------------------------------------------------------------------------- /step07_map/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": false, 7 | "emitDecoratorMetadata": false, 8 | "experimentalDecorators": false, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | } 12 | } -------------------------------------------------------------------------------- /step07_map/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalDependencies": { 3 | "core-js": "registry:dt/core-js#0.0.0+20160602141332", 4 | "node": "registry:dt/node#6.0.0+20160621231320" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /step07_map/typings/globals/core-js/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts", 5 | "raw": "registry:dt/core-js#0.0.0+20160602141332", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step07_map/typings/globals/node/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts", 5 | "raw": "registry:dt/node#6.0.0+20160621231320", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step07_map/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /step08_filter_even/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /step08_filter_even/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Launch", 6 | "type": "node", 7 | "request": "launch", 8 | "program": "${workspaceRoot}app.ts", 9 | "stopOnEntry": false, 10 | "args": [], 11 | "cwd": "${workspaceRoot}", 12 | "runtimeExecutable": null, 13 | "runtimeArgs": [ 14 | "--nolazy" 15 | ], 16 | "env": { 17 | "NODE_ENV": "development" 18 | }, 19 | "externalConsole": false, 20 | "sourceMaps": false, 21 | "outDir": null 22 | }, 23 | { 24 | "name": "Attach", 25 | "type": "node", 26 | "request": "attach", 27 | "port": 5858, 28 | "sourceMaps": false, 29 | "outDir": null, 30 | "localRoot": "${workspaceRoot}", 31 | "remoteRoot": null 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /step08_filter_even/app.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Rx = require('rxjs/Rx'); 3 | var src = Rx.Observable.range(1, 5); 4 | var upper = src.filter(function (val) { 5 | return val % 2 !== 0; 6 | }); 7 | upper.subscribe(function (val) { 8 | console.log(val); 9 | }); 10 | -------------------------------------------------------------------------------- /step08_filter_even/app.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":";AAAA,IAAO,EAAE,WAAW,SAAS,CAAC,CAAC;AAE/B,IAAI,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEpC,IAAI,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,UAAS,GAAW;IACvC,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC;AAEH,KAAK,CAAC,SAAS,CAAC,UAAS,GAAG;IACxB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACpB,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /step08_filter_even/app.ts: -------------------------------------------------------------------------------- 1 | import Rx = require('rxjs/Rx'); 2 | 3 | var src = Rx.Observable.range(1, 5); 4 | 5 | var upper = src.filter(function(val: number) { 6 | return val % 2 !== 0; 7 | }); 8 | 9 | upper.subscribe(function(val) { 10 | console.log(val) 11 | }); 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /step08_filter_even/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "step00_helloworld", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.ts", 6 | "devDependencies": {}, 7 | "scripts": { 8 | "start": "tsc && node app", 9 | "typings": "typings", 10 | "postinstall": "typings install" 11 | }, 12 | "author": "Zia Khan", 13 | "license": "ISC", 14 | "dependencies": { 15 | "rxjs": "^5.0.0-beta.9" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /step08_filter_even/readme.md: -------------------------------------------------------------------------------- 1 | This step covers the chapter 2 code on page 20 of the following book using RxJS 5 and TypeScript: 2 | 3 | http://www.amazon.com/Reactive-Programming-RxJS-Asynchronous-JavaScript-ebook/dp/B01ATYZTI4/ 4 | 5 | 6 | To run: 7 | 8 | npm install 9 | 10 | npm start 11 | 12 | -------------------------------------------------------------------------------- /step08_filter_even/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": false, 7 | "emitDecoratorMetadata": false, 8 | "experimentalDecorators": false, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | } 12 | } -------------------------------------------------------------------------------- /step08_filter_even/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalDependencies": { 3 | "core-js": "registry:dt/core-js#0.0.0+20160602141332", 4 | "node": "registry:dt/node#6.0.0+20160621231320" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /step08_filter_even/typings/globals/core-js/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts", 5 | "raw": "registry:dt/core-js#0.0.0+20160602141332", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step08_filter_even/typings/globals/node/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts", 5 | "raw": "registry:dt/node#6.0.0+20160621231320", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step08_filter_even/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /step09_reduce/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /step09_reduce/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Launch", 6 | "type": "node", 7 | "request": "launch", 8 | "program": "${workspaceRoot}app.ts", 9 | "stopOnEntry": false, 10 | "args": [], 11 | "cwd": "${workspaceRoot}", 12 | "runtimeExecutable": null, 13 | "runtimeArgs": [ 14 | "--nolazy" 15 | ], 16 | "env": { 17 | "NODE_ENV": "development" 18 | }, 19 | "externalConsole": false, 20 | "sourceMaps": false, 21 | "outDir": null 22 | }, 23 | { 24 | "name": "Attach", 25 | "type": "node", 26 | "request": "attach", 27 | "port": 5858, 28 | "sourceMaps": false, 29 | "outDir": null, 30 | "localRoot": "${workspaceRoot}", 31 | "remoteRoot": null 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /step09_reduce/app.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Rx = require('rxjs/Rx'); 3 | var src = Rx.Observable.range(1, 5); 4 | var upper = src.reduce(function (acc, val) { return acc + val; }); 5 | upper.subscribe(function (val) { 6 | console.log(val); 7 | }); 8 | -------------------------------------------------------------------------------- /step09_reduce/app.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":";AAAA,IAAO,EAAE,WAAW,SAAS,CAAC,CAAC;AAE/B,IAAI,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEpC,IAAI,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,UAAS,GAAW,EAAE,GAAW;IACpD,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;AACrB,CAAC,CAAC,CAAC;AAEH,KAAK,CAAC,SAAS,CAAC,UAAS,GAAG;IACxB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACpB,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /step09_reduce/app.ts: -------------------------------------------------------------------------------- 1 | import Rx = require('rxjs/Rx'); 2 | 3 | var src = Rx.Observable.range(1, 5); 4 | 5 | var upper = src.reduce((acc: number, val: number) => { return acc + val; }); 6 | 7 | upper.subscribe(function(val) { 8 | console.log(val) 9 | }); 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /step09_reduce/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "step00_helloworld", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.ts", 6 | "devDependencies": {}, 7 | "scripts": { 8 | "start": "tsc && node app", 9 | "typings": "typings", 10 | "postinstall": "typings install" 11 | }, 12 | "author": "Zia Khan", 13 | "license": "ISC", 14 | "dependencies": { 15 | "rxjs": "^5.0.0-beta.9" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /step09_reduce/readme.md: -------------------------------------------------------------------------------- 1 | This step covers the chapter 2 code on page 21 of the following book using RxJS 5 and TypeScript: 2 | 3 | http://www.amazon.com/Reactive-Programming-RxJS-Asynchronous-JavaScript-ebook/dp/B01ATYZTI4/ 4 | 5 | 6 | To run: 7 | 8 | npm install 9 | 10 | npm start 11 | 12 | -------------------------------------------------------------------------------- /step09_reduce/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": false, 7 | "emitDecoratorMetadata": false, 8 | "experimentalDecorators": false, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | } 12 | } -------------------------------------------------------------------------------- /step09_reduce/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalDependencies": { 3 | "core-js": "registry:dt/core-js#0.0.0+20160602141332", 4 | "node": "registry:dt/node#6.0.0+20160621231320" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /step09_reduce/typings/globals/core-js/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts", 5 | "raw": "registry:dt/core-js#0.0.0+20160602141332", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step09_reduce/typings/globals/node/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts", 5 | "raw": "registry:dt/node#6.0.0+20160621231320", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step09_reduce/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /step10_reduce_average/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /step10_reduce_average/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Launch", 6 | "type": "node", 7 | "request": "launch", 8 | "program": "${workspaceRoot}app.ts", 9 | "stopOnEntry": false, 10 | "args": [], 11 | "cwd": "${workspaceRoot}", 12 | "runtimeExecutable": null, 13 | "runtimeArgs": [ 14 | "--nolazy" 15 | ], 16 | "env": { 17 | "NODE_ENV": "development" 18 | }, 19 | "externalConsole": false, 20 | "sourceMaps": false, 21 | "outDir": null 22 | }, 23 | { 24 | "name": "Attach", 25 | "type": "node", 26 | "request": "attach", 27 | "port": 5858, 28 | "sourceMaps": false, 29 | "outDir": null, 30 | "localRoot": "${workspaceRoot}", 31 | "remoteRoot": null 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /step10_reduce_average/app.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Rx = require('rxjs/Rx'); 3 | var range = Rx.Observable.range(0, 5); 4 | var avg = range.reduce(function (prev, cur) { 5 | return { 6 | sum: prev.sum + cur, 7 | count: prev.count + 1 8 | }; 9 | }, { sum: 0, count: 0 }) 10 | .map(function (o) { 11 | return o.sum / o.count; 12 | }); 13 | var subscription = avg.subscribe(function (x) { 14 | console.log('Average is: ', x); 15 | }); 16 | -------------------------------------------------------------------------------- /step10_reduce_average/app.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":";AAAA,IAAO,EAAE,WAAW,SAAS,CAAC,CAAC;AAE/B,IAAI,KAAK,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACtC,IAAI,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,UAAC,IAAI,EAAE,GAAG;IAC7B,MAAM,CAAC;QACH,GAAG,EAAE,IAAI,CAAC,GAAG,GAAG,GAAG;QACnB,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC;KACxB,CAAC;AACN,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;KACvB,GAAG,CAAC,UAAC,CAAC;IACH,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC;AAC3B,CAAC,CAAC,CAAC;AACH,IAAI,YAAY,GAAG,GAAG,CAAC,SAAS,CAAC,UAAC,CAAC;IAC/B,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;AACnC,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /step10_reduce_average/app.ts: -------------------------------------------------------------------------------- 1 | import Rx = require('rxjs/Rx'); 2 | 3 | var range = Rx.Observable.range(0, 5); 4 | var avg = range.reduce((prev, cur) => { 5 | return { 6 | sum: prev.sum + cur, 7 | count: prev.count + 1 8 | }; 9 | }, { sum: 0, count: 0 }) 10 | .map((o) => { 11 | return o.sum / o.count; 12 | }); 13 | var subscription = avg.subscribe((x) => { 14 | console.log('Average is: ', x); 15 | }); 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /step10_reduce_average/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "step00_helloworld", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.ts", 6 | "devDependencies": {}, 7 | "scripts": { 8 | "start": "tsc && node app", 9 | "typings": "typings", 10 | "postinstall": "typings install" 11 | }, 12 | "author": "Zia Khan", 13 | "license": "ISC", 14 | "dependencies": { 15 | "rxjs": "^5.0.0-beta.9" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /step10_reduce_average/readme.md: -------------------------------------------------------------------------------- 1 | This step covers the chapter 2 code on page 21 of the following book using RxJS 5 and TypeScript: 2 | 3 | http://www.amazon.com/Reactive-Programming-RxJS-Asynchronous-JavaScript-ebook/dp/B01ATYZTI4/ 4 | 5 | 6 | To run: 7 | 8 | npm install 9 | 10 | npm start 11 | 12 | -------------------------------------------------------------------------------- /step10_reduce_average/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": false, 7 | "emitDecoratorMetadata": false, 8 | "experimentalDecorators": false, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | } 12 | } -------------------------------------------------------------------------------- /step10_reduce_average/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalDependencies": { 3 | "core-js": "registry:dt/core-js#0.0.0+20160602141332", 4 | "node": "registry:dt/node#6.0.0+20160621231320" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /step10_reduce_average/typings/globals/core-js/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts", 5 | "raw": "registry:dt/core-js#0.0.0+20160602141332", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step10_reduce_average/typings/globals/node/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts", 5 | "raw": "registry:dt/node#6.0.0+20160621231320", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step10_reduce_average/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /step11_scan/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /step11_scan/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Launch", 6 | "type": "node", 7 | "request": "launch", 8 | "program": "${workspaceRoot}app.ts", 9 | "stopOnEntry": false, 10 | "args": [], 11 | "cwd": "${workspaceRoot}", 12 | "runtimeExecutable": null, 13 | "runtimeArgs": [ 14 | "--nolazy" 15 | ], 16 | "env": { 17 | "NODE_ENV": "development" 18 | }, 19 | "externalConsole": false, 20 | "sourceMaps": false, 21 | "outDir": null 22 | }, 23 | { 24 | "name": "Attach", 25 | "type": "node", 26 | "request": "attach", 27 | "port": 5858, 28 | "sourceMaps": false, 29 | "outDir": null, 30 | "localRoot": "${workspaceRoot}", 31 | "remoteRoot": null 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /step11_scan/app.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Rx = require('rxjs/Rx'); 3 | var avg = Rx.Observable.interval(1000) 4 | .scan(function (prev, cur) { 5 | return { 6 | sum: prev.sum + cur, 7 | count: prev.count + 1 8 | }; 9 | }, { sum: 0, count: 0 }) 10 | .map(function (o) { 11 | return o.sum / o.count; 12 | }); 13 | var subscription = avg.subscribe(function (x) { 14 | console.log(x); 15 | }); 16 | -------------------------------------------------------------------------------- /step11_scan/app.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":";AAAA,IAAO,EAAE,WAAW,SAAS,CAAC,CAAC;AAE/B,IAAI,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC;KACrC,IAAI,CAAC,UAAC,IAAI,EAAE,GAAG;IACZ,MAAM,CAAC;QACH,GAAG,EAAE,IAAI,CAAC,GAAG,GAAG,GAAG;QACnB,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC;KACxB,CAAC;AACN,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;KACvB,GAAG,CAAC,UAAC,CAAC;IACH,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC;AAC3B,CAAC,CAAC,CAAC;AACH,IAAI,YAAY,GAAG,GAAG,CAAC,SAAS,CAAE,UAAU,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /step11_scan/app.ts: -------------------------------------------------------------------------------- 1 | import Rx = require('rxjs/Rx'); 2 | 3 | var avg = Rx.Observable.interval(1000) 4 | .scan((prev, cur) => { 5 | return { 6 | sum: prev.sum + cur, 7 | count: prev.count + 1 8 | }; 9 | }, { sum: 0, count: 0 }) 10 | .map((o) => { 11 | return o.sum / o.count; 12 | }); 13 | var subscription = avg.subscribe( function (x) { 14 | console.log(x); 15 | }); 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /step11_scan/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "step00_helloworld", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.ts", 6 | "devDependencies": {}, 7 | "scripts": { 8 | "start": "tsc && node app", 9 | "typings": "typings", 10 | "postinstall": "typings install" 11 | }, 12 | "author": "Zia Khan", 13 | "license": "ISC", 14 | "dependencies": { 15 | "rxjs": "^5.0.0-beta.9" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /step11_scan/readme.md: -------------------------------------------------------------------------------- 1 | This step covers the chapter 2 code on page 21 of the following book using RxJS 5 and TypeScript: 2 | 3 | http://www.amazon.com/Reactive-Programming-RxJS-Asynchronous-JavaScript-ebook/dp/B01ATYZTI4/ 4 | 5 | 6 | To run: 7 | 8 | npm install 9 | 10 | npm start 11 | 12 | -------------------------------------------------------------------------------- /step11_scan/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": false, 7 | "emitDecoratorMetadata": false, 8 | "experimentalDecorators": false, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | } 12 | } -------------------------------------------------------------------------------- /step11_scan/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalDependencies": { 3 | "core-js": "registry:dt/core-js#0.0.0+20160602141332", 4 | "node": "registry:dt/node#6.0.0+20160621231320" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /step11_scan/typings/globals/core-js/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts", 5 | "raw": "registry:dt/core-js#0.0.0+20160602141332", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step11_scan/typings/globals/node/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts", 5 | "raw": "registry:dt/node#6.0.0+20160621231320", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step11_scan/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /step12_subject/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /step12_subject/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // Available variables which can be used inside of strings. 2 | // ${workspaceRoot}: the root folder of the team 3 | // ${file}: the current opened file 4 | // ${fileBasename}: the current opened file's basename 5 | // ${fileDirname}: the current opened file's dirname 6 | // ${fileExtname}: the current opened file's extension 7 | // ${cwd}: the current working directory of the spawned process 8 | 9 | // A task runner that calls the Typescript compiler (tsc) and 10 | // Compiles a HelloWorld.ts program 11 | { 12 | "version": "0.1.0", 13 | 14 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 15 | "command": "tsc", 16 | 17 | // The command is a shell script 18 | "isShellCommand": true, 19 | 20 | // Show the output window only if unrecognized errors occur. 21 | "showOutput": "silent", 22 | 23 | // args is the HelloWorld program to compile. 24 | "args": ["app.ts"], 25 | 26 | // use the standard tsc problem matcher to find compile problems 27 | // in the output. 28 | "problemMatcher": "$tsc" 29 | } 30 | 31 | // A task runner that calls the Typescript compiler (tsc) and 32 | // compiles based on a tsconfig.json file that is present in 33 | // the root of the folder open in VSCode 34 | /* 35 | { 36 | "version": "0.1.0", 37 | 38 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 39 | "command": "tsc", 40 | 41 | // The command is a shell script 42 | "isShellCommand": true, 43 | 44 | // Show the output window only if unrecognized errors occur. 45 | "showOutput": "silent", 46 | 47 | // Tell the tsc compiler to use the tsconfig.json from the open folder. 48 | "args": ["-p", "."], 49 | 50 | // use the standard tsc problem matcher to find compile problems 51 | // in the output. 52 | "problemMatcher": "$tsc" 53 | } 54 | */ 55 | 56 | // A task runner configuration for gulp. Gulp provides a less task 57 | // which compiles less to css. 58 | /* 59 | { 60 | "version": "0.1.0", 61 | "command": "gulp", 62 | "isShellCommand": true, 63 | "tasks": [ 64 | { 65 | "taskName": "less", 66 | // Make this the default build command. 67 | "isBuildCommand": true, 68 | // Show the output window only if unrecognized errors occur. 69 | "showOutput": "silent", 70 | // Use the standard less compilation problem matcher. 71 | "problemMatcher": "$lessCompile" 72 | } 73 | ] 74 | } 75 | */ 76 | 77 | // Uncomment the following section to use jake to build a workspace 78 | // cloned from https://github.com/Microsoft/TypeScript.git 79 | /* 80 | { 81 | "version": "0.1.0", 82 | // Task runner is jake 83 | "command": "jake", 84 | // Need to be executed in shell / cmd 85 | "isShellCommand": true, 86 | "showOutput": "silent", 87 | "tasks": [ 88 | { 89 | // TS build command is local. 90 | "taskName": "local", 91 | // Make this the default build command. 92 | "isBuildCommand": true, 93 | // Show the output window only if unrecognized errors occur. 94 | "showOutput": "silent", 95 | // Use the redefined Typescript output problem matcher. 96 | "problemMatcher": [ 97 | "$tsc" 98 | ] 99 | } 100 | ] 101 | } 102 | */ 103 | 104 | // Uncomment the section below to use msbuild and generate problems 105 | // for csc, cpp, tsc and vb. The configuration assumes that msbuild 106 | // is available on the path and a solution file exists in the 107 | // workspace folder root. 108 | /* 109 | { 110 | "version": "0.1.0", 111 | "command": "msbuild", 112 | "args": [ 113 | // Ask msbuild to generate full paths for file names. 114 | "/property:GenerateFullPaths=true" 115 | ], 116 | "taskSelector": "/t:", 117 | "showOutput": "silent", 118 | "tasks": [ 119 | { 120 | "taskName": "build", 121 | // Show the output window only if unrecognized errors occur. 122 | "showOutput": "silent", 123 | // Use the standard MS compiler pattern to detect errors, warnings 124 | // and infos in the output. 125 | "problemMatcher": "$msCompile" 126 | } 127 | ] 128 | } 129 | */ 130 | 131 | // Uncomment the following section to use msbuild which compiles Typescript 132 | // and less files. 133 | /* 134 | { 135 | "version": "0.1.0", 136 | "command": "msbuild", 137 | "args": [ 138 | // Ask msbuild to generate full paths for file names. 139 | "/property:GenerateFullPaths=true" 140 | ], 141 | "taskSelector": "/t:", 142 | "showOutput": "silent", 143 | "tasks": [ 144 | { 145 | "taskName": "build", 146 | // Show the output window only if unrecognized errors occur. 147 | "showOutput": "silent", 148 | // Use the standard MS compiler pattern to detect errors, warnings 149 | // and infos in the output. 150 | "problemMatcher": [ 151 | "$msCompile", 152 | "$lessCompile" 153 | ] 154 | } 155 | ] 156 | } 157 | */ 158 | // A task runner example that defines a problemMatcher inline instead of using 159 | // a predfined one. 160 | /* 161 | { 162 | "version": "0.1.0", 163 | "command": "tsc", 164 | "isShellCommand": true, 165 | "args": ["HelloWorld.ts"], 166 | "showOutput": "silent", 167 | "problemMatcher": { 168 | // The problem is owned by the typescript language service. Ensure that the problems 169 | // are merged with problems produced by Visual Studio's language service. 170 | "owner": "typescript", 171 | // The file name for reported problems is relative to the current working directory. 172 | "fileLocation": ["relative", "${cwd}"], 173 | // The actual pattern to match problems in the output. 174 | "pattern": { 175 | // The regular expression. Matches HelloWorld.ts(2,10): error TS2339: Property 'logg' does not exist on type 'Console'. 176 | "regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$", 177 | // The match group that denotes the file containing the problem. 178 | "file": 1, 179 | // The match group that denotes the problem location. 180 | "location": 2, 181 | // The match group that denotes the problem's severity. Can be omitted. 182 | "severity": 3, 183 | // The match group that denotes the problem code. Can be omitted. 184 | "code": 4, 185 | // The match group that denotes the problem's message. 186 | "message": 5 187 | } 188 | } 189 | } 190 | */ -------------------------------------------------------------------------------- /step12_subject/app.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Rx = require('rxjs/Rx'); 3 | //A Subject allows us to push and pull values to the underlying Observable. 4 | var simpleStream$ = new Rx.Subject(); 5 | simpleStream$.subscribe(function (value) { 6 | console.log("first: " + value); 7 | }); 8 | simpleStream$.next("a"); 9 | simpleStream$.next("b"); 10 | simpleStream$.subscribe(function (value) { 11 | console.log("second: " + value); 12 | }); 13 | simpleStream$.next("c"); 14 | simpleStream$.next("d"); 15 | -------------------------------------------------------------------------------- /step12_subject/app.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":";AAAA,IAAO,EAAE,WAAW,SAAS,CAAC,CAAC;AAE/B,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,aAAa,CAAC;KAC5B,SAAS,CAAC,UAAS,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /step12_subject/app.ts: -------------------------------------------------------------------------------- 1 | import Rx = require('rxjs/Rx'); 2 | //A Subject allows us to push and pull values to the underlying Observable. 3 | const simpleStream$ = new Rx.Subject(); 4 | 5 | simpleStream$.subscribe((value) => { 6 | console.log("firstObservable: " + value); 7 | }); 8 | 9 | simpleStream$.next("a"); 10 | simpleStream$.next("b"); 11 | 12 | 13 | simpleStream$.subscribe((value) => { 14 | console.log("secondObservable: " + value); 15 | }); 16 | 17 | simpleStream$.next("c"); 18 | simpleStream$.next("d"); 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /step12_subject/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "step00_helloworld", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.ts", 6 | "devDependencies": {}, 7 | "scripts": { 8 | "start": "tsc && node app", 9 | "typings": "typings", 10 | "postinstall": "typings install" 11 | }, 12 | "author": "Zia Khan", 13 | "license": "ISC", 14 | "dependencies": { 15 | "rxjs": "^5.0.0-beta.9" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /step12_subject/readme.md: -------------------------------------------------------------------------------- 1 | Read: 2 | 3 | http://reactivex.io/rxjs/manual/overview.html#subject 4 | 5 | "Subject has one particularity that prevents us from using it to build observable data services: 6 | if we subscribe to it we won't get the last value, we will have to wait until some part of the app calls next()." 7 | 8 | http://blog.angular-university.io/how-to-build-angular2-apps-using-rxjs-observable-data-services-pitfalls-to-avoid/ 9 | 10 | Also read: 11 | 12 | http://juristr.com/blog/2016/06/rxjs-1st-steps-subject/ 13 | 14 | https://coryrylan.com/blog/angular-2-observable-data-services -------------------------------------------------------------------------------- /step12_subject/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": false, 7 | "emitDecoratorMetadata": false, 8 | "experimentalDecorators": false, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | } 12 | } -------------------------------------------------------------------------------- /step12_subject/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalDependencies": { 3 | "core-js": "registry:dt/core-js#0.0.0+20160602141332", 4 | "node": "registry:dt/node#6.0.0+20160621231320" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /step12_subject/typings/globals/core-js/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts", 5 | "raw": "registry:dt/core-js#0.0.0+20160602141332", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step12_subject/typings/globals/node/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts", 5 | "raw": "registry:dt/node#6.0.0+20160621231320", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step12_subject/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /step13_behavior_subject/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /step13_behavior_subject/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // Available variables which can be used inside of strings. 2 | // ${workspaceRoot}: the root folder of the team 3 | // ${file}: the current opened file 4 | // ${fileBasename}: the current opened file's basename 5 | // ${fileDirname}: the current opened file's dirname 6 | // ${fileExtname}: the current opened file's extension 7 | // ${cwd}: the current working directory of the spawned process 8 | 9 | // A task runner that calls the Typescript compiler (tsc) and 10 | // Compiles a HelloWorld.ts program 11 | { 12 | "version": "0.1.0", 13 | 14 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 15 | "command": "tsc", 16 | 17 | // The command is a shell script 18 | "isShellCommand": true, 19 | 20 | // Show the output window only if unrecognized errors occur. 21 | "showOutput": "silent", 22 | 23 | // args is the HelloWorld program to compile. 24 | "args": ["app.ts"], 25 | 26 | // use the standard tsc problem matcher to find compile problems 27 | // in the output. 28 | "problemMatcher": "$tsc" 29 | } 30 | 31 | // A task runner that calls the Typescript compiler (tsc) and 32 | // compiles based on a tsconfig.json file that is present in 33 | // the root of the folder open in VSCode 34 | /* 35 | { 36 | "version": "0.1.0", 37 | 38 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 39 | "command": "tsc", 40 | 41 | // The command is a shell script 42 | "isShellCommand": true, 43 | 44 | // Show the output window only if unrecognized errors occur. 45 | "showOutput": "silent", 46 | 47 | // Tell the tsc compiler to use the tsconfig.json from the open folder. 48 | "args": ["-p", "."], 49 | 50 | // use the standard tsc problem matcher to find compile problems 51 | // in the output. 52 | "problemMatcher": "$tsc" 53 | } 54 | */ 55 | 56 | // A task runner configuration for gulp. Gulp provides a less task 57 | // which compiles less to css. 58 | /* 59 | { 60 | "version": "0.1.0", 61 | "command": "gulp", 62 | "isShellCommand": true, 63 | "tasks": [ 64 | { 65 | "taskName": "less", 66 | // Make this the default build command. 67 | "isBuildCommand": true, 68 | // Show the output window only if unrecognized errors occur. 69 | "showOutput": "silent", 70 | // Use the standard less compilation problem matcher. 71 | "problemMatcher": "$lessCompile" 72 | } 73 | ] 74 | } 75 | */ 76 | 77 | // Uncomment the following section to use jake to build a workspace 78 | // cloned from https://github.com/Microsoft/TypeScript.git 79 | /* 80 | { 81 | "version": "0.1.0", 82 | // Task runner is jake 83 | "command": "jake", 84 | // Need to be executed in shell / cmd 85 | "isShellCommand": true, 86 | "showOutput": "silent", 87 | "tasks": [ 88 | { 89 | // TS build command is local. 90 | "taskName": "local", 91 | // Make this the default build command. 92 | "isBuildCommand": true, 93 | // Show the output window only if unrecognized errors occur. 94 | "showOutput": "silent", 95 | // Use the redefined Typescript output problem matcher. 96 | "problemMatcher": [ 97 | "$tsc" 98 | ] 99 | } 100 | ] 101 | } 102 | */ 103 | 104 | // Uncomment the section below to use msbuild and generate problems 105 | // for csc, cpp, tsc and vb. The configuration assumes that msbuild 106 | // is available on the path and a solution file exists in the 107 | // workspace folder root. 108 | /* 109 | { 110 | "version": "0.1.0", 111 | "command": "msbuild", 112 | "args": [ 113 | // Ask msbuild to generate full paths for file names. 114 | "/property:GenerateFullPaths=true" 115 | ], 116 | "taskSelector": "/t:", 117 | "showOutput": "silent", 118 | "tasks": [ 119 | { 120 | "taskName": "build", 121 | // Show the output window only if unrecognized errors occur. 122 | "showOutput": "silent", 123 | // Use the standard MS compiler pattern to detect errors, warnings 124 | // and infos in the output. 125 | "problemMatcher": "$msCompile" 126 | } 127 | ] 128 | } 129 | */ 130 | 131 | // Uncomment the following section to use msbuild which compiles Typescript 132 | // and less files. 133 | /* 134 | { 135 | "version": "0.1.0", 136 | "command": "msbuild", 137 | "args": [ 138 | // Ask msbuild to generate full paths for file names. 139 | "/property:GenerateFullPaths=true" 140 | ], 141 | "taskSelector": "/t:", 142 | "showOutput": "silent", 143 | "tasks": [ 144 | { 145 | "taskName": "build", 146 | // Show the output window only if unrecognized errors occur. 147 | "showOutput": "silent", 148 | // Use the standard MS compiler pattern to detect errors, warnings 149 | // and infos in the output. 150 | "problemMatcher": [ 151 | "$msCompile", 152 | "$lessCompile" 153 | ] 154 | } 155 | ] 156 | } 157 | */ 158 | // A task runner example that defines a problemMatcher inline instead of using 159 | // a predfined one. 160 | /* 161 | { 162 | "version": "0.1.0", 163 | "command": "tsc", 164 | "isShellCommand": true, 165 | "args": ["HelloWorld.ts"], 166 | "showOutput": "silent", 167 | "problemMatcher": { 168 | // The problem is owned by the typescript language service. Ensure that the problems 169 | // are merged with problems produced by Visual Studio's language service. 170 | "owner": "typescript", 171 | // The file name for reported problems is relative to the current working directory. 172 | "fileLocation": ["relative", "${cwd}"], 173 | // The actual pattern to match problems in the output. 174 | "pattern": { 175 | // The regular expression. Matches HelloWorld.ts(2,10): error TS2339: Property 'logg' does not exist on type 'Console'. 176 | "regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$", 177 | // The match group that denotes the file containing the problem. 178 | "file": 1, 179 | // The match group that denotes the problem location. 180 | "location": 2, 181 | // The match group that denotes the problem's severity. Can be omitted. 182 | "severity": 3, 183 | // The match group that denotes the problem code. Can be omitted. 184 | "code": 4, 185 | // The match group that denotes the problem's message. 186 | "message": 5 187 | } 188 | } 189 | } 190 | */ -------------------------------------------------------------------------------- /step13_behavior_subject/app.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Rx = require('rxjs/Rx'); 3 | //A Subject allows us to push and pull values to the underlying Observable. 4 | var simpleStream$ = new Rx.BehaviorSubject("z"); 5 | simpleStream$.subscribe(function (value) { 6 | console.log("first: " + value); 7 | }); 8 | simpleStream$.next("a"); 9 | simpleStream$.next("b"); 10 | simpleStream$.subscribe(function (value) { 11 | console.log("second: " + value); 12 | }); 13 | simpleStream$.next("c"); 14 | simpleStream$.next("d"); 15 | -------------------------------------------------------------------------------- /step13_behavior_subject/app.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":";AAAA,IAAO,EAAE,WAAW,SAAS,CAAC,CAAC;AAE/B,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,aAAa,CAAC;KAC5B,SAAS,CAAC,UAAS,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /step13_behavior_subject/app.ts: -------------------------------------------------------------------------------- 1 | import Rx = require('rxjs/Rx'); 2 | //A Subject allows us to push and pull values to the underlying Observable. 3 | const simpleStream$ = new Rx.BehaviorSubject("z"); 4 | 5 | simpleStream$.subscribe((value) => { 6 | console.log("firstObserver: " + value); 7 | }); 8 | 9 | simpleStream$.next("a"); 10 | simpleStream$.next("b"); 11 | 12 | 13 | simpleStream$.subscribe((value) => { 14 | console.log("secondObserver: " + value); 15 | }); 16 | 17 | simpleStream$.next("c"); 18 | simpleStream$.next("d"); 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /step13_behavior_subject/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "step00_helloworld", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.ts", 6 | "devDependencies": {}, 7 | "scripts": { 8 | "start": "tsc && node app", 9 | "typings": "typings", 10 | "postinstall": "typings install" 11 | }, 12 | "author": "Zia Khan", 13 | "license": "ISC", 14 | "dependencies": { 15 | "rxjs": "^5.0.0-beta.9" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /step13_behavior_subject/readme.md: -------------------------------------------------------------------------------- 1 | "What BehaviorSubject does is that it will return upon subscription 2 | the last value of the stream, or an initial state if no value was emitted yet" 3 | 4 | http://blog.angular-university.io/how-to-build-angular2-apps-using-rxjs-observable-data-services-pitfalls-to-avoid/ 5 | 6 | 7 | http://reactivex.io/rxjs/manual/overview.html#behaviorsubject 8 | -------------------------------------------------------------------------------- /step13_behavior_subject/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": false, 7 | "emitDecoratorMetadata": false, 8 | "experimentalDecorators": false, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | } 12 | } -------------------------------------------------------------------------------- /step13_behavior_subject/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalDependencies": { 3 | "core-js": "registry:dt/core-js#0.0.0+20160602141332", 4 | "node": "registry:dt/node#6.0.0+20160621231320" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /step13_behavior_subject/typings/globals/core-js/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts", 5 | "raw": "registry:dt/core-js#0.0.0+20160602141332", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step13_behavior_subject/typings/globals/node/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts", 5 | "raw": "registry:dt/node#6.0.0+20160621231320", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step13_behavior_subject/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /step14_replay_subject/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /step14_replay_subject/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // Available variables which can be used inside of strings. 2 | // ${workspaceRoot}: the root folder of the team 3 | // ${file}: the current opened file 4 | // ${fileBasename}: the current opened file's basename 5 | // ${fileDirname}: the current opened file's dirname 6 | // ${fileExtname}: the current opened file's extension 7 | // ${cwd}: the current working directory of the spawned process 8 | 9 | // A task runner that calls the Typescript compiler (tsc) and 10 | // Compiles a HelloWorld.ts program 11 | { 12 | "version": "0.1.0", 13 | 14 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 15 | "command": "tsc", 16 | 17 | // The command is a shell script 18 | "isShellCommand": true, 19 | 20 | // Show the output window only if unrecognized errors occur. 21 | "showOutput": "silent", 22 | 23 | // args is the HelloWorld program to compile. 24 | "args": ["app.ts"], 25 | 26 | // use the standard tsc problem matcher to find compile problems 27 | // in the output. 28 | "problemMatcher": "$tsc" 29 | } 30 | 31 | // A task runner that calls the Typescript compiler (tsc) and 32 | // compiles based on a tsconfig.json file that is present in 33 | // the root of the folder open in VSCode 34 | /* 35 | { 36 | "version": "0.1.0", 37 | 38 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 39 | "command": "tsc", 40 | 41 | // The command is a shell script 42 | "isShellCommand": true, 43 | 44 | // Show the output window only if unrecognized errors occur. 45 | "showOutput": "silent", 46 | 47 | // Tell the tsc compiler to use the tsconfig.json from the open folder. 48 | "args": ["-p", "."], 49 | 50 | // use the standard tsc problem matcher to find compile problems 51 | // in the output. 52 | "problemMatcher": "$tsc" 53 | } 54 | */ 55 | 56 | // A task runner configuration for gulp. Gulp provides a less task 57 | // which compiles less to css. 58 | /* 59 | { 60 | "version": "0.1.0", 61 | "command": "gulp", 62 | "isShellCommand": true, 63 | "tasks": [ 64 | { 65 | "taskName": "less", 66 | // Make this the default build command. 67 | "isBuildCommand": true, 68 | // Show the output window only if unrecognized errors occur. 69 | "showOutput": "silent", 70 | // Use the standard less compilation problem matcher. 71 | "problemMatcher": "$lessCompile" 72 | } 73 | ] 74 | } 75 | */ 76 | 77 | // Uncomment the following section to use jake to build a workspace 78 | // cloned from https://github.com/Microsoft/TypeScript.git 79 | /* 80 | { 81 | "version": "0.1.0", 82 | // Task runner is jake 83 | "command": "jake", 84 | // Need to be executed in shell / cmd 85 | "isShellCommand": true, 86 | "showOutput": "silent", 87 | "tasks": [ 88 | { 89 | // TS build command is local. 90 | "taskName": "local", 91 | // Make this the default build command. 92 | "isBuildCommand": true, 93 | // Show the output window only if unrecognized errors occur. 94 | "showOutput": "silent", 95 | // Use the redefined Typescript output problem matcher. 96 | "problemMatcher": [ 97 | "$tsc" 98 | ] 99 | } 100 | ] 101 | } 102 | */ 103 | 104 | // Uncomment the section below to use msbuild and generate problems 105 | // for csc, cpp, tsc and vb. The configuration assumes that msbuild 106 | // is available on the path and a solution file exists in the 107 | // workspace folder root. 108 | /* 109 | { 110 | "version": "0.1.0", 111 | "command": "msbuild", 112 | "args": [ 113 | // Ask msbuild to generate full paths for file names. 114 | "/property:GenerateFullPaths=true" 115 | ], 116 | "taskSelector": "/t:", 117 | "showOutput": "silent", 118 | "tasks": [ 119 | { 120 | "taskName": "build", 121 | // Show the output window only if unrecognized errors occur. 122 | "showOutput": "silent", 123 | // Use the standard MS compiler pattern to detect errors, warnings 124 | // and infos in the output. 125 | "problemMatcher": "$msCompile" 126 | } 127 | ] 128 | } 129 | */ 130 | 131 | // Uncomment the following section to use msbuild which compiles Typescript 132 | // and less files. 133 | /* 134 | { 135 | "version": "0.1.0", 136 | "command": "msbuild", 137 | "args": [ 138 | // Ask msbuild to generate full paths for file names. 139 | "/property:GenerateFullPaths=true" 140 | ], 141 | "taskSelector": "/t:", 142 | "showOutput": "silent", 143 | "tasks": [ 144 | { 145 | "taskName": "build", 146 | // Show the output window only if unrecognized errors occur. 147 | "showOutput": "silent", 148 | // Use the standard MS compiler pattern to detect errors, warnings 149 | // and infos in the output. 150 | "problemMatcher": [ 151 | "$msCompile", 152 | "$lessCompile" 153 | ] 154 | } 155 | ] 156 | } 157 | */ 158 | // A task runner example that defines a problemMatcher inline instead of using 159 | // a predfined one. 160 | /* 161 | { 162 | "version": "0.1.0", 163 | "command": "tsc", 164 | "isShellCommand": true, 165 | "args": ["HelloWorld.ts"], 166 | "showOutput": "silent", 167 | "problemMatcher": { 168 | // The problem is owned by the typescript language service. Ensure that the problems 169 | // are merged with problems produced by Visual Studio's language service. 170 | "owner": "typescript", 171 | // The file name for reported problems is relative to the current working directory. 172 | "fileLocation": ["relative", "${cwd}"], 173 | // The actual pattern to match problems in the output. 174 | "pattern": { 175 | // The regular expression. Matches HelloWorld.ts(2,10): error TS2339: Property 'logg' does not exist on type 'Console'. 176 | "regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$", 177 | // The match group that denotes the file containing the problem. 178 | "file": 1, 179 | // The match group that denotes the problem location. 180 | "location": 2, 181 | // The match group that denotes the problem's severity. Can be omitted. 182 | "severity": 3, 183 | // The match group that denotes the problem code. Can be omitted. 184 | "code": 4, 185 | // The match group that denotes the problem's message. 186 | "message": 5 187 | } 188 | } 189 | } 190 | */ -------------------------------------------------------------------------------- /step14_replay_subject/app.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Rx = require('rxjs/Rx'); 3 | //A Subject allows us to push and pull values to the underlying Observable. 4 | var simpleStream$ = new Rx.ReplaySubject(2); 5 | simpleStream$.subscribe(function (value) { 6 | console.log("first: " + value); 7 | }); 8 | simpleStream$.next("a"); 9 | simpleStream$.next("b"); 10 | simpleStream$.subscribe(function (value) { 11 | console.log("second: " + value); 12 | }); 13 | simpleStream$.next("c"); 14 | simpleStream$.next("d"); 15 | -------------------------------------------------------------------------------- /step14_replay_subject/app.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":";AAAA,IAAO,EAAE,WAAW,SAAS,CAAC,CAAC;AAE/B,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,aAAa,CAAC;KAC5B,SAAS,CAAC,UAAS,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /step14_replay_subject/app.ts: -------------------------------------------------------------------------------- 1 | import Rx = require('rxjs/Rx'); 2 | //A Subject allows us to push and pull values to the underlying Observable. 3 | const simpleStream$ = new Rx.ReplaySubject(2); 4 | 5 | simpleStream$.subscribe((value) => { 6 | console.log("firstObserver: " + value); 7 | }); 8 | 9 | simpleStream$.next("a"); 10 | simpleStream$.next("b"); 11 | 12 | 13 | simpleStream$.subscribe((value) => { 14 | console.log("secondObserver: " + value); 15 | }); 16 | 17 | simpleStream$.next("c"); 18 | simpleStream$.next("d"); 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /step14_replay_subject/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "step00_helloworld", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.ts", 6 | "devDependencies": {}, 7 | "scripts": { 8 | "start": "tsc && node app", 9 | "typings": "typings", 10 | "postinstall": "typings install" 11 | }, 12 | "author": "Zia Khan", 13 | "license": "ISC", 14 | "dependencies": { 15 | "rxjs": "^5.0.0-beta.9" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /step14_replay_subject/readme.md: -------------------------------------------------------------------------------- 1 | ReplaySubject represents an object that is both an observable sequence as well as an observer. 2 | Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies. 3 | ReplaySubject stores all the values that it has published. Therefore, when you subscribe to it, you automatically receive an entire history of values that it has published, even though your subscription might have come in after certain values have been pushed out. 4 | 5 | http://reactivex.io/rxjs/manual/overview.html#replaysubject 6 | 7 | http://juristr.com/blog/2016/06/rxjs-1st-steps-subject/ 8 | -------------------------------------------------------------------------------- /step14_replay_subject/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": false, 7 | "emitDecoratorMetadata": false, 8 | "experimentalDecorators": false, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | } 12 | } -------------------------------------------------------------------------------- /step14_replay_subject/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalDependencies": { 3 | "core-js": "registry:dt/core-js#0.0.0+20160602141332", 4 | "node": "registry:dt/node#6.0.0+20160621231320" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /step14_replay_subject/typings/globals/core-js/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts", 5 | "raw": "registry:dt/core-js#0.0.0+20160602141332", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step14_replay_subject/typings/globals/node/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts", 5 | "raw": "registry:dt/node#6.0.0+20160621231320", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step14_replay_subject/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /step15_async_subject/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /step15_async_subject/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // Available variables which can be used inside of strings. 2 | // ${workspaceRoot}: the root folder of the team 3 | // ${file}: the current opened file 4 | // ${fileBasename}: the current opened file's basename 5 | // ${fileDirname}: the current opened file's dirname 6 | // ${fileExtname}: the current opened file's extension 7 | // ${cwd}: the current working directory of the spawned process 8 | 9 | // A task runner that calls the Typescript compiler (tsc) and 10 | // Compiles a HelloWorld.ts program 11 | { 12 | "version": "0.1.0", 13 | 14 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 15 | "command": "tsc", 16 | 17 | // The command is a shell script 18 | "isShellCommand": true, 19 | 20 | // Show the output window only if unrecognized errors occur. 21 | "showOutput": "silent", 22 | 23 | // args is the HelloWorld program to compile. 24 | "args": ["app.ts"], 25 | 26 | // use the standard tsc problem matcher to find compile problems 27 | // in the output. 28 | "problemMatcher": "$tsc" 29 | } 30 | 31 | // A task runner that calls the Typescript compiler (tsc) and 32 | // compiles based on a tsconfig.json file that is present in 33 | // the root of the folder open in VSCode 34 | /* 35 | { 36 | "version": "0.1.0", 37 | 38 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 39 | "command": "tsc", 40 | 41 | // The command is a shell script 42 | "isShellCommand": true, 43 | 44 | // Show the output window only if unrecognized errors occur. 45 | "showOutput": "silent", 46 | 47 | // Tell the tsc compiler to use the tsconfig.json from the open folder. 48 | "args": ["-p", "."], 49 | 50 | // use the standard tsc problem matcher to find compile problems 51 | // in the output. 52 | "problemMatcher": "$tsc" 53 | } 54 | */ 55 | 56 | // A task runner configuration for gulp. Gulp provides a less task 57 | // which compiles less to css. 58 | /* 59 | { 60 | "version": "0.1.0", 61 | "command": "gulp", 62 | "isShellCommand": true, 63 | "tasks": [ 64 | { 65 | "taskName": "less", 66 | // Make this the default build command. 67 | "isBuildCommand": true, 68 | // Show the output window only if unrecognized errors occur. 69 | "showOutput": "silent", 70 | // Use the standard less compilation problem matcher. 71 | "problemMatcher": "$lessCompile" 72 | } 73 | ] 74 | } 75 | */ 76 | 77 | // Uncomment the following section to use jake to build a workspace 78 | // cloned from https://github.com/Microsoft/TypeScript.git 79 | /* 80 | { 81 | "version": "0.1.0", 82 | // Task runner is jake 83 | "command": "jake", 84 | // Need to be executed in shell / cmd 85 | "isShellCommand": true, 86 | "showOutput": "silent", 87 | "tasks": [ 88 | { 89 | // TS build command is local. 90 | "taskName": "local", 91 | // Make this the default build command. 92 | "isBuildCommand": true, 93 | // Show the output window only if unrecognized errors occur. 94 | "showOutput": "silent", 95 | // Use the redefined Typescript output problem matcher. 96 | "problemMatcher": [ 97 | "$tsc" 98 | ] 99 | } 100 | ] 101 | } 102 | */ 103 | 104 | // Uncomment the section below to use msbuild and generate problems 105 | // for csc, cpp, tsc and vb. The configuration assumes that msbuild 106 | // is available on the path and a solution file exists in the 107 | // workspace folder root. 108 | /* 109 | { 110 | "version": "0.1.0", 111 | "command": "msbuild", 112 | "args": [ 113 | // Ask msbuild to generate full paths for file names. 114 | "/property:GenerateFullPaths=true" 115 | ], 116 | "taskSelector": "/t:", 117 | "showOutput": "silent", 118 | "tasks": [ 119 | { 120 | "taskName": "build", 121 | // Show the output window only if unrecognized errors occur. 122 | "showOutput": "silent", 123 | // Use the standard MS compiler pattern to detect errors, warnings 124 | // and infos in the output. 125 | "problemMatcher": "$msCompile" 126 | } 127 | ] 128 | } 129 | */ 130 | 131 | // Uncomment the following section to use msbuild which compiles Typescript 132 | // and less files. 133 | /* 134 | { 135 | "version": "0.1.0", 136 | "command": "msbuild", 137 | "args": [ 138 | // Ask msbuild to generate full paths for file names. 139 | "/property:GenerateFullPaths=true" 140 | ], 141 | "taskSelector": "/t:", 142 | "showOutput": "silent", 143 | "tasks": [ 144 | { 145 | "taskName": "build", 146 | // Show the output window only if unrecognized errors occur. 147 | "showOutput": "silent", 148 | // Use the standard MS compiler pattern to detect errors, warnings 149 | // and infos in the output. 150 | "problemMatcher": [ 151 | "$msCompile", 152 | "$lessCompile" 153 | ] 154 | } 155 | ] 156 | } 157 | */ 158 | // A task runner example that defines a problemMatcher inline instead of using 159 | // a predfined one. 160 | /* 161 | { 162 | "version": "0.1.0", 163 | "command": "tsc", 164 | "isShellCommand": true, 165 | "args": ["HelloWorld.ts"], 166 | "showOutput": "silent", 167 | "problemMatcher": { 168 | // The problem is owned by the typescript language service. Ensure that the problems 169 | // are merged with problems produced by Visual Studio's language service. 170 | "owner": "typescript", 171 | // The file name for reported problems is relative to the current working directory. 172 | "fileLocation": ["relative", "${cwd}"], 173 | // The actual pattern to match problems in the output. 174 | "pattern": { 175 | // The regular expression. Matches HelloWorld.ts(2,10): error TS2339: Property 'logg' does not exist on type 'Console'. 176 | "regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$", 177 | // The match group that denotes the file containing the problem. 178 | "file": 1, 179 | // The match group that denotes the problem location. 180 | "location": 2, 181 | // The match group that denotes the problem's severity. Can be omitted. 182 | "severity": 3, 183 | // The match group that denotes the problem code. Can be omitted. 184 | "code": 4, 185 | // The match group that denotes the problem's message. 186 | "message": 5 187 | } 188 | } 189 | } 190 | */ -------------------------------------------------------------------------------- /step15_async_subject/app.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Rx = require('rxjs/Rx'); 3 | //A Subject allows us to push and pull values to the underlying Observable. 4 | var simpleStream$ = new Rx.AsyncSubject(); 5 | simpleStream$.subscribe(function (value) { 6 | console.log("firstObserver: " + value); 7 | }); 8 | simpleStream$.next("a"); 9 | simpleStream$.next("b"); 10 | simpleStream$.subscribe(function (value) { 11 | console.log("secondObserver: " + value); 12 | }); 13 | simpleStream$.next("c"); 14 | simpleStream$.next("d"); 15 | simpleStream$.complete(); 16 | -------------------------------------------------------------------------------- /step15_async_subject/app.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":";AAAA,IAAO,EAAE,WAAW,SAAS,CAAC,CAAC;AAE/B,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,aAAa,CAAC;KAC5B,SAAS,CAAC,UAAS,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /step15_async_subject/app.ts: -------------------------------------------------------------------------------- 1 | import Rx = require('rxjs/Rx'); 2 | //The AsyncSubject is a variant where only the last value of the Observable execution is sent to its observers, 3 | //and only when the execution completes. 4 | const simpleStream$ = new Rx.AsyncSubject(); 5 | 6 | simpleStream$.subscribe((value) => { 7 | console.log("firstObserver: " + value); 8 | }); 9 | 10 | simpleStream$.next("a"); 11 | simpleStream$.next("b"); 12 | 13 | 14 | simpleStream$.subscribe((value) => { 15 | console.log("secondObserver: " + value); 16 | }); 17 | 18 | simpleStream$.next("c"); 19 | simpleStream$.next("d"); 20 | 21 | simpleStream$.complete();//comment this out and no event will be sent 22 | 23 | 24 | -------------------------------------------------------------------------------- /step15_async_subject/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "step00_helloworld", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.ts", 6 | "devDependencies": {}, 7 | "scripts": { 8 | "start": "tsc && node app", 9 | "typings": "typings", 10 | "postinstall": "typings install" 11 | }, 12 | "author": "Zia Khan", 13 | "license": "ISC", 14 | "dependencies": { 15 | "rxjs": "^5.0.0-beta.9" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /step15_async_subject/readme.md: -------------------------------------------------------------------------------- 1 | http://reactivex.io/rxjs/manual/overview.html#asyncsubject 2 | -------------------------------------------------------------------------------- /step15_async_subject/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "sourceMap": false, 7 | "emitDecoratorMetadata": false, 8 | "experimentalDecorators": false, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | } 12 | } -------------------------------------------------------------------------------- /step15_async_subject/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalDependencies": { 3 | "core-js": "registry:dt/core-js#0.0.0+20160602141332", 4 | "node": "registry:dt/node#6.0.0+20160621231320" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /step15_async_subject/typings/globals/core-js/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts", 5 | "raw": "registry:dt/core-js#0.0.0+20160602141332", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/95e782233e8e203a0b9283c3a7031faee428a530/core-js/core-js.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step15_async_subject/typings/globals/node/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts", 5 | "raw": "registry:dt/node#6.0.0+20160621231320", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6a78438776c5719aefa02f96f1d7fa2dbc0edfce/node/node.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /step15_async_subject/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /step_extra_browser_es5/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /step_extra_browser_es5/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // Available variables which can be used inside of strings. 2 | // ${workspaceRoot}: the root folder of the team 3 | // ${file}: the current opened file 4 | // ${fileBasename}: the current opened file's basename 5 | // ${fileDirname}: the current opened file's dirname 6 | // ${fileExtname}: the current opened file's extension 7 | // ${cwd}: the current working directory of the spawned process 8 | 9 | // A task runner that calls the Typescript compiler (tsc) and 10 | // Compiles a HelloWorld.ts program 11 | { 12 | "version": "0.1.0", 13 | 14 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 15 | "command": "tsc", 16 | 17 | // The command is a shell script 18 | "isShellCommand": true, 19 | 20 | // Show the output window only if unrecognized errors occur. 21 | "showOutput": "silent", 22 | 23 | // args is the HelloWorld program to compile. 24 | "args": ["app.ts"], 25 | 26 | // use the standard tsc problem matcher to find compile problems 27 | // in the output. 28 | "problemMatcher": "$tsc" 29 | } 30 | 31 | // A task runner that calls the Typescript compiler (tsc) and 32 | // compiles based on a tsconfig.json file that is present in 33 | // the root of the folder open in VSCode 34 | /* 35 | { 36 | "version": "0.1.0", 37 | 38 | // The command is tsc. Assumes that tsc has been installed using npm install -g typescript 39 | "command": "tsc", 40 | 41 | // The command is a shell script 42 | "isShellCommand": true, 43 | 44 | // Show the output window only if unrecognized errors occur. 45 | "showOutput": "silent", 46 | 47 | // Tell the tsc compiler to use the tsconfig.json from the open folder. 48 | "args": ["-p", "."], 49 | 50 | // use the standard tsc problem matcher to find compile problems 51 | // in the output. 52 | "problemMatcher": "$tsc" 53 | } 54 | */ 55 | 56 | // A task runner configuration for gulp. Gulp provides a less task 57 | // which compiles less to css. 58 | /* 59 | { 60 | "version": "0.1.0", 61 | "command": "gulp", 62 | "isShellCommand": true, 63 | "tasks": [ 64 | { 65 | "taskName": "less", 66 | // Make this the default build command. 67 | "isBuildCommand": true, 68 | // Show the output window only if unrecognized errors occur. 69 | "showOutput": "silent", 70 | // Use the standard less compilation problem matcher. 71 | "problemMatcher": "$lessCompile" 72 | } 73 | ] 74 | } 75 | */ 76 | 77 | // Uncomment the following section to use jake to build a workspace 78 | // cloned from https://github.com/Microsoft/TypeScript.git 79 | /* 80 | { 81 | "version": "0.1.0", 82 | // Task runner is jake 83 | "command": "jake", 84 | // Need to be executed in shell / cmd 85 | "isShellCommand": true, 86 | "showOutput": "silent", 87 | "tasks": [ 88 | { 89 | // TS build command is local. 90 | "taskName": "local", 91 | // Make this the default build command. 92 | "isBuildCommand": true, 93 | // Show the output window only if unrecognized errors occur. 94 | "showOutput": "silent", 95 | // Use the redefined Typescript output problem matcher. 96 | "problemMatcher": [ 97 | "$tsc" 98 | ] 99 | } 100 | ] 101 | } 102 | */ 103 | 104 | // Uncomment the section below to use msbuild and generate problems 105 | // for csc, cpp, tsc and vb. The configuration assumes that msbuild 106 | // is available on the path and a solution file exists in the 107 | // workspace folder root. 108 | /* 109 | { 110 | "version": "0.1.0", 111 | "command": "msbuild", 112 | "args": [ 113 | // Ask msbuild to generate full paths for file names. 114 | "/property:GenerateFullPaths=true" 115 | ], 116 | "taskSelector": "/t:", 117 | "showOutput": "silent", 118 | "tasks": [ 119 | { 120 | "taskName": "build", 121 | // Show the output window only if unrecognized errors occur. 122 | "showOutput": "silent", 123 | // Use the standard MS compiler pattern to detect errors, warnings 124 | // and infos in the output. 125 | "problemMatcher": "$msCompile" 126 | } 127 | ] 128 | } 129 | */ 130 | 131 | // Uncomment the following section to use msbuild which compiles Typescript 132 | // and less files. 133 | /* 134 | { 135 | "version": "0.1.0", 136 | "command": "msbuild", 137 | "args": [ 138 | // Ask msbuild to generate full paths for file names. 139 | "/property:GenerateFullPaths=true" 140 | ], 141 | "taskSelector": "/t:", 142 | "showOutput": "silent", 143 | "tasks": [ 144 | { 145 | "taskName": "build", 146 | // Show the output window only if unrecognized errors occur. 147 | "showOutput": "silent", 148 | // Use the standard MS compiler pattern to detect errors, warnings 149 | // and infos in the output. 150 | "problemMatcher": [ 151 | "$msCompile", 152 | "$lessCompile" 153 | ] 154 | } 155 | ] 156 | } 157 | */ 158 | // A task runner example that defines a problemMatcher inline instead of using 159 | // a predfined one. 160 | /* 161 | { 162 | "version": "0.1.0", 163 | "command": "tsc", 164 | "isShellCommand": true, 165 | "args": ["HelloWorld.ts"], 166 | "showOutput": "silent", 167 | "problemMatcher": { 168 | // The problem is owned by the typescript language service. Ensure that the problems 169 | // are merged with problems produced by Visual Studio's language service. 170 | "owner": "typescript", 171 | // The file name for reported problems is relative to the current working directory. 172 | "fileLocation": ["relative", "${cwd}"], 173 | // The actual pattern to match problems in the output. 174 | "pattern": { 175 | // The regular expression. Matches HelloWorld.ts(2,10): error TS2339: Property 'logg' does not exist on type 'Console'. 176 | "regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$", 177 | // The match group that denotes the file containing the problem. 178 | "file": 1, 179 | // The match group that denotes the problem location. 180 | "location": 2, 181 | // The match group that denotes the problem's severity. Can be omitted. 182 | "severity": 3, 183 | // The match group that denotes the problem code. Can be omitted. 184 | "code": 4, 185 | // The match group that denotes the problem's message. 186 | "message": 5 187 | } 188 | } 189 | } 190 | */ -------------------------------------------------------------------------------- /step_extra_browser_es5/app/main.js: -------------------------------------------------------------------------------- 1 | var subject = new Rx.Subject(); 2 | 3 | Rx.Observable.from([1,2,3]) 4 | .scan((count, change) => count + change) 5 | .subscribe(x => console.log(x)); -------------------------------------------------------------------------------- /step_extra_browser_es5/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | RxJS Sample in ES5 directly in Browser 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /step_extra_browser_es5/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rxjs-in-browser", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "start": "lite-server" 6 | }, 7 | "license": "ISC", 8 | "dependencies": { 9 | "rxjs": "^5.0.0-beta.9" 10 | }, 11 | "devDependencies": { 12 | "lite-server": "^2.2.0" 13 | } 14 | } -------------------------------------------------------------------------------- /step_extra_browser_es5/readme.md: -------------------------------------------------------------------------------- 1 | Using RxJS5 straight from browser (ES5) 2 | 3 | https://github.com/ReactiveX/RxJS/issues/1274 --------------------------------------------------------------------------------