Skip to content

Instantly share code, notes, and snippets.

@stemcstudio
Last active August 12, 2017 14:58
Show Gist options
  • Save stemcstudio/6cf885c38435f0b59c9b1391339b46d2 to your computer and use it in GitHub Desktop.
Save stemcstudio/6cf885c38435f0b59c9b1391339b46d2 to your computer and use it in GitHub Desktop.
RxJS Observables from Arrays

RxJS: Observables From Arrays

Copyright (c) 2016-2017 David Geo Holmes.

<!DOCTYPE html>
<!--
STEMCstudio HTML file template.
The marker below comments define the locations for CSS, CSV, GLSL,
JavaScript and transpiled TypeScript insertion.
You may make changes to this file, but these markers should be preseved.
Please refer to the User Guide for more details.
-->
<html>
<head>
<base href='/'>
<!-- STYLES-MARKER -->
<style>
/* STYLE-MARKER */
</style>
<!-- SYSTEM-SHIM-MARKER -->
<!-- CSV-FILES-MARKER -->
<!-- SHADERS-MARKER -->
<!-- SCRIPTS-MARKER -->
</head>
<body>
<div id='out'></div>
<script>
// CODE-MARKER
</script>
<script>
System.defaultJSExtensions = true
System.import('./index')
</script>
</body>
</html>
import { Observable } from 'rxjs/Rx'
const out = document.querySelector('#out') as HTMLDivElement
const numbers = [1, 2, 3, 4, 5, 6]
const stream = Observable.from(numbers)
stream.subscribe(
function(x) {
console.log(x)
out.appendChild(document.createTextNode(`${x}`))
},
function(reason) {
console.warn(reason)
},
function() {
console.log('Completed')
}
)
{
"description": "RxJS Observables from Arrays",
"dependencies": {
"rxjs/Rx": "5.3.3"
},
"name": "",
"version": "1.0.0",
"keywords": [
"RxJS",
"reactivex",
"STEMCstudio"
],
"author": "David Geo Holmes",
"linting": true,
"hideConfigFiles": true
}
body {
color:#369;
font-family: Arial, Helvetica, sans-serif;
}
{
"allowJs": true,
"checkJs": true,
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"jsx": "react",
"module": "system",
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"preserveConstEnums": true,
"removeComments": false,
"skipLibCheck": true,
"sourceMap": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"target": "es5",
"traceResolution": true
}
{
"rules": {
"array-type": [
true,
"array"
],
"curly": false,
"comment-format": [
true,
"check-space"
],
"eofline": true,
"forin": true,
"jsdoc-format": true,
"new-parens": true,
"no-conditional-assignment": false,
"no-consecutive-blank-lines": true,
"no-construct": true,
"no-for-in-array": true,
"no-inferrable-types": [
true
],
"no-magic-numbers": false,
"no-shadowed-variable": true,
"no-string-throw": true,
"no-trailing-whitespace": [
true,
"ignore-jsdoc"
],
"no-var-keyword": true,
"one-variable-per-declaration": [
true,
"ignore-for-loop"
],
"prefer-const": true,
"prefer-for-of": true,
"prefer-function-over-method": false,
"prefer-method-signature": true,
"radix": true,
"semicolon": [
true,
"never"
],
"trailing-comma": [
true,
{
"multiline": "never",
"singleline": "never"
}
],
"triple-equals": true,
"use-isnan": true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment