const next = (message)=> console.log("First observer message: " + message);
const error = (error) => console.log("Second observer error: " + error);
const complete = () => console.log("complete");
const next1 = (message)=> console.log("First observer message 1: " + message);
const error1 = (error) => console.log("Second observer error 1: " + error);
const complete1 = () => console.log("complete 1");
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script src="https://code.jquery.com/jquery-3.1.0.js"></script> | |
<h1 id="title">Hola</h1> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script src="https://code.jquery.com/jquery-3.1.0.js"></script> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arr = [1,2,4][Symbol.iterator]() | |
console.log('Next in array_as_iterable 1', arr.next()) | |
// Next in array_as_iterable 1 | |
// {value: 1, done: false } | |
console.log('Next in array_as_iterable 2', arr.next()) | |
// Next in array_as_iterable 2 | |
// {value: 2, done: false } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//se crea la función generadora con la anotación "function*" | |
const arr = function* arrGen(){ | |
yield 1 // yield detiene la función, devuelve 1 y cuándo se ejecute de nuevo next() | |
// continuá en la siguiente linea de código la #5 | |
yield 2 // yield detiene la función, devuelve 2 y cuándo se ejecute de nuevo next() | |
// continuá en la siguiente linea de código la #7 | |
yield 4 // yield detiene la función, devuelve 2 y cuándo se ejecute de nuevo next() | |
// devulve undefined y la propiedad done igual a true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//importar la librería IxJS | |
const Ix = require('ix'); | |
//Crea la fuente de datos con una función async generator | |
async function* arrGen() { | |
yield 1; | |
yield 2; | |
yield 4; | |
} | |
//Crea un objeto que IxJS entienda; Async Iterable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Ix = require('ix'); | |
async function* arrGen() { | |
yield 1; | |
yield 2; | |
yield 4; | |
} | |
const results = Ix.AsyncIterable.from(arrGen()) | |
.filter(x => x % 2 === 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Basic Types: boolean, string, arrays, number, | |
// null, undefined, void, object, never, Symbol | |
var grettings: string = "Hola esto es un string"; | |
grettings = {attendets: "gracias por venir"}; //error | |
//capturar comportamientos inesperados | |
const sumWeird = {attendets: "Hola"} + ["como estan"]; //error | |
//Type inference |