Skip to content

Instantly share code, notes, and snippets.

@maniator
Last active April 28, 2017 21:43
Show Gist options
  • Save maniator/80fc62753e233b0a34ae0c00d827f212 to your computer and use it in GitHub Desktop.
Save maniator/80fc62753e233b0a34ae0c00d827f212 to your computer and use it in GitHub Desktop.
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
const Observable = require('servable').Observable;
const inputObservable$ = new Observable(function ({ next }) {
const input = document.getElementById('myInput');
const listener = function () {
const { value } = input;
next(value);
};
input.addEventListener('input', listener, false);
return function () {
input.removeEventListener('input', listener, false);
};
});
const div = document.getElementById('myText');
inputObservable$.subscribe(
function (value) {
div.textContent = value;
}
)
setTimeout(function(){
;require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"servable":[function(require,module,exports){
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["Servable"] = factory();
else
root["Servable"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Observable; });
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var noop = function noop() {};
var Observable = function () {
function Observable(observerCallback) {
_classCallCheck(this, Observable);
this.observerCallback = observerCallback;
}
Observable.prototype.subscribe = function subscribe() {
var next = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : noop;
var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
var complete = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : noop;
var isComplete = false;
var observer = {
next: next,
error: error,
complete: complete
};
var dispose = noop;
var unsubscribe = function unsubscribe() {
observer.next = noop;
observer.error = noop;
observer.complete = noop;
dispose();
};
observer.next = function () {
if (!isComplete) {
next.apply(undefined, arguments);
}
};
observer.error = function () {
error.apply(undefined, arguments);
unsubscribe();
};
observer.complete = function () {
if (!isComplete) {
complete();
unsubscribe();
}
isComplete = true;
};
try {
var disposable = this.observerCallback.bind(this, observer)();
if (typeof disposable === 'function') {
dispose = disposable;
}
} catch (e) {
error(e);
}
return unsubscribe;
};
return Observable;
}();
/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__servable__ = __webpack_require__(0);
/* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return __WEBPACK_IMPORTED_MODULE_0__servable__["a"]; });
/***/ })
/******/ ]);
});
},{}]},{},[])
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL2hvbWUvYWRtaW4vYnJvd3NlcmlmeS1jZG4vbm9kZV9tb2R1bGVzL2Jyb3dzZXJpZnkvbm9kZV9tb2R1bGVzL2Jyb3dzZXItcGFjay9fcHJlbHVkZS5qcyIsInNlcnZhYmxlIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBO0FDQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtB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18oMCk7XG4vKiBoYXJtb255IG5hbWVzcGFjZSByZWV4cG9ydCAoYnkgcHJvdmlkZWQpICovIF9fd2VicGFja19yZXF1aXJlX18uZChfX3dlYnBhY2tfZXhwb3J0c19fLCBcIk9ic2VydmFibGVcIiwgZnVuY3Rpb24oKSB7IHJldHVybiBfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzBfX3NlcnZhYmxlX19bXCJhXCJdOyB9KTtcblxuXG4vKioqLyB9KVxuLyoqKioqKi8gXSk7XG59KTsiXX0=
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
const Observable = require('servable').Observable;
const inputObservable$ = new Observable(function ({ next }) {
const input = document.getElementById('myInput');
const listener = function () {
const { value } = input;
next(value);
};
input.addEventListener('input', listener, false);
return function () {
input.removeEventListener('input', listener, false);
};
});
const div = document.getElementById('myText');
inputObservable$.subscribe(
function (value) {
div.textContent = value;
}
)
;}, 0)
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"servable": "0.0.5"
}
}
<!-- contents of this file will be placed inside the <body> -->
<div id="myText">Type in input</div>
<input id="myInput" value="Type in input" />
<!-- contents of this file will be placed inside the <head> -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment