Skip to content

Instantly share code, notes, and snippets.

View rohanBagchi's full-sized avatar

Rohan Bagchi rohanBagchi

View GitHub Profile
import { connect } from 'react-redux';
import App from './App';
function mapStateToProps(state) {
return {};
}
function mapDispatchToProps(dispatch) {
return {};
}
import React, { Component } from 'react';
import PropTypes from 'prop-types';
class App extends Component {
render() {
return (
<div className="container">
<div className="row">
<div className="col-md-12">
{this.props.message}
function Foo() {
this.name = 'Hello';
}
function Bar() {
Foo.call(this);
this.age = 31;
}
function Foo() {
this.name = 'Hello';
}
function Bar() {
Foo.call(this);
this.age = 31;
}
Bar.prototype = Object.create(Foo.prototype);
function Foo() {
this.name = 'Hello';
}
function Bar() {
Foo.call(this);
this.age = 31;
}
Bar.prototype = Object.create(Foo.prototype);
var PENDING = 1;
var RESOLVED = 2;
var REJECTED = 3;
var PENDING = 1;
var RESOLVED = 2;
var REJECTED = 3;
function Promise(executorFunction) {
var status = PENDING;
var resolve = function (value) {
if (status !== PENDING) return;
try {
success_callbacks.forEach(cb => cb.call(null, value));
success_callbacks = [];
status = RESOLVED;
} catch (e) {
this.reject(e);
}
var reject = function (err) {
if (status !== PENDING) return;
error_callbacks.forEach(cb => cb.call(null, err));
error_callbacks = [];
status = REJECTED;
};
(function main() {
getLargeNumber()
.then(function (number) {
console.log('We got ' + number);
});
})();
function getLargeNumber() {
return new Promise(function (resolve, reject) {
setTimeout(() => {
(() => {
const btn = document.getElementById("calculate_btn");
const res = document.getElementById("result");
btn.addEventListener("click", e => {
res.innerHTML = "Loading...";
const val = doLongCalculation();
const shortenedData = val.slice(0, 50).join(", ") + "...";
res.innerHTML = shortenedData;
});
})();