Skip to content

Instantly share code, notes, and snippets.

View Mayankgupta688's full-sized avatar
💭
Corporate and Online Trainer with 8+ years of Experience...

Mayank Gupta Mayankgupta688

💭
Corporate and Online Trainer with 8+ years of Experience...
View GitHub Profile
function createObserverFromArray() {
// Creating Observable from Array
let source = from([1, 2, 3, 4, 67]);
source.subscribe({
next: function(value) {
console.log(`input data ${value}`);
}
import { fromEvent } from 'rxjs';
const clicksInDocument = fromEvent(document, 'click');
const clicksInDiv = fromEvent(document.getElementById("articleDiv", 'click');
import { fromEvent } from 'rxjs';
const clicksInDocument = fromEvent(document, 'click');
clickInDocument.subscribe(function(event) {
console.log("X Co-ordinates for click Event: " + event.x);
console.log("Y Co-ordinates for click Event: " + event.y);
});
document.getElementById("articleDiv").addEventListener("click", function(event) {
console.log("X Co-ordinates for Click Event: " + event.x)
});
import { Observable } from 'rxjs';
var randomNumberGenerator = Observable.create(function(observer) {
setTimeout(function() {
var randomNumber = Math.floor(Math.random() * 100);
if(randomNumber == 13) {
observer.error("Incorrect Random Number Generated");
import { Observable } from 'rxjs';
var randomNumberGenerator = Observable.create(function(observer) {
observer.next(Math.floor(Math.random() * 100));
observer.next(Math.floor(Math.random() * 100));
observer.next(Math.floor(Math.random() * 100));
observer.next(Math.floor(Math.random() * 100));
observer.next(Math.floor(Math.random() * 100));
observer.next(Math.floor(Math.random() * 100));
import { Observable } from 'rxjs';
var randomNumberGenerator = Observable.create(function(observer) {
observer.next(Math.floor(Math.random() * 100));
observer.next(Math.floor(Math.random() * 100));
observer.next(Math.floor(Math.random() * 100));
observer.next(Math.floor(Math.random() * 100));
observer.next(Math.floor(Math.random() * 100));
observer.next(Math.floor(Math.random() * 100));
observer.next(Math.floor(Math.random() * 100));
import { Observable } from 'rxjs';
var randomNumberGenerator = Observable.create(function(observer) {
setTimeout(function() {
var randomNumber = Math.floor(Math.random() * 100);
if(randomNumber == 13) {
observer.error("Incorrect Random Number Generated");
} else if(randomNumber == 99) {
import React from 'react';
var newData = {
data: 'Data from HOC...',
}
var MyHOC = ComposedComponent => class extends React.Component {
componentDidMount() {
this.setState({
data: newData.data
import React from "react";
export default function ShowEmployeeBasicDetails(props) {
return (
<div>
<p>Employee Name: {props.name}</p>
<p>Employee Age: {props.age}</p>
<p>Employee Designation: {props.designation}</p>
</div>