Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
requirebin sketch
var o = require('observable')
var h = require('hyperscript')
var field = h('input', {'type': 'text'})
value = o.input(field)
value(function(v){
console.log('changed to', v)
})
setTimeout(function(){
value('hello') // doesn't fire handler at line 7
}, 1000)
document.body.appendChild(field)
require=function(n,t,e){function r(e,u){if(!t[e]){if(!n[e]){var i="function"==typeof require&&require;if(!u&&i)return i(e,!0);if(o)return o(e,!0);throw Error("Cannot find module '"+e+"'")}var c=t[e]={exports:{}};n[e][0].call(c.exports,function(t){var o=n[e][1][t];return r(o?o:t)},c,c.exports)}return t[e].exports}for(var o="function"==typeof require&&require,u=0;e.length>u;u++)r(e[u]);return r}({observable:[function(n,t){t.exports=n("WN4afR")},{}],WN4afR:[function(n,t){(function(){function n(n,t){n(t()),t(n)}function e(n,t){t(n()),n(t),t(n)}function r(n){return void 0===n}function o(n){return"function"!=typeof n}function u(n){return"function"==typeof n}function i(n){if(!u(n))throw Error("transform expects an observable");return n}function c(n,t){for(var e in n)n[e](t)}function f(n,t){delete n[n.indexOf(t)]}function a(n,t,e){(n.on||n.addEventListener).call(n,t,e,!1)}function l(n,t,e){(n.removeListener||n.removeEventListener||n.off).call(n,t,e,!1)}function s(){var n,t=[];return function(e){return r(e)?n:o(e)?c(t,n=e):(t.push(e),e(n),function(){f(t,e)})}}function p(n,t){return function(e){return r(e)?n.get(t):o(e)?n.set(t,e):(a(n,"change:"+t,e),e(n.get(t)),function(){l(n,"change:"+t,e)})}}function v(n,t,e){return i(n),function(u){return r(u)?t(n()):o(u)?n((e||t)(u)):n(function(n){u(t(n))})}}function d(n){return v(n,function(n){return!n})}function h(n,t,e,r){function o(){r(u(e)?e():n[e])}return a(n,t,o),o(),function(){l(n,t,o)}}function g(n,t,e){return t=t||"value",e=e||"input",function(u){return r(u)?n[t]:o(u)?n[t]=u:h(n,e,t,u)}}function y(n){function t(){return n[n.selectedIndex].value}function e(t){for(var e=0;n.options.length>e;e++)n.options[e].value==t&&(n.selectedIndex=e)}return function(u){return r(u)?n.options[n.selectedIndex].value:o(u)?e(u):h(n,"change",t,u)}}function b(n,t,e){var u=!1;return function(i){function c(){u||i(u=!0)}function f(){u&&i(u=!1)}return r(i)?u:o(i)?void 0:(a(n,t,c),a(n,e||t,f),i(u),function(){l(n,t,c),l(n,e||t,f)})}}function x(n,t){var e=[],r=!0,o=s();return n.forEach(function(n,u){n(function(n){e[u]=n,r||o(t.apply(null,e))})}),r=!1,o(function(){t.apply(null,e)}),o}function m(n,t,e){return v(n,function(n){return n?t:e},function(n){return n==t?!0:!1})}function w(){var n,t=[];return function(e){return r(e)?n:o(e)?n!==e?c(t,n=e):"":(t.push(e),e(n),function(){f(t,e)})}}var E=s;E.bind1=n,E.bind2=e,E.value=s,E.not=d,E.property=p,E.input=E.attribute=g,E.select=y,E.compute=x,E.transform=v,E.boolean=m,E.toggle=b,E.hover=function(n){return b(n,"mouseover","mouseout")},E.focus=function(n){return b(n,"focus","blur")},E.signal=w,"object"==typeof t?t.exports=E:this.observable=E})()},{}]},{},[]),require=function(n,t,e){function r(e,u){if(!t[e]){if(!n[e]){var i="function"==typeof require&&require;if(!u&&i)return i(e,!0);if(o)return o(e,!0);throw Error("Cannot find module '"+e+"'")}var c=t[e]={exports:{}};n[e][0].call(c.exports,function(t){var o=n[e][1][t];return r(o?o:t)},c,c.exports)}return t[e].exports}for(var o="function"==typeof require&&require,u=0;e.length>u;u++)r(e[u]);return r}({1:[function(){},{}],hyperscript:[function(n,t){t.exports=n("eJU+xQ")},{}],"eJU+xQ":[function(n,t){function e(){function n(t){function a(n){var t=i(n,/([\.#]?[a-zA-Z0-9_-]+)/);o(t,function(n){var t=n.substring(1,n.length);n&&(e?"."===n[0]?c(e).add(t):"#"===n[0]&&e.setAttribute("id",t):e=document.createElement(n))})}var l;if(null==t);else if("string"==typeof t)e?e.appendChild(l=document.createTextNode(t)):a(t);else if("number"==typeof t||"boolean"==typeof t||t instanceof Date||t instanceof RegExp)e.appendChild(l=document.createTextNode(""+t));else if(u(t))o(t,n);else if(r(t))e.appendChild(l=t);else if(t instanceof Text)e.appendChild(l=t);else if("object"==typeof t)for(var s in t)if("function"==typeof t[s])/^on\w+/.test(s)?e.addEventListener?e.addEventListener(s.substring(2),t[s],!1):e.attachEvent(s,t[s]):(e[s]=t[s](),t[s](function(n){e[s]=n}));else if("style"===s)for(var p in t[s])(function(n,r){"function"==typeof r?(e.style.setProperty(n,r()),r(function(t){e.style.setProperty(n,t)})):e.style.setProperty(n,t[s][n])})(p,t[s][p]);else"data-"===s.substr(0,5)?f(e)[s.substr(5)]=t[s]:e[s]=t[s];else if("function"==typeof t){var v=t();e.appendChild(l=r(v)?v:document.createTextNode(v)),t(function(n){r(n)&&l.parentElement?(l.parentElement.replaceChild(n,l),l=n):l.textContent=n})}return l}for(var t=[].slice.call(arguments),e=null;t.length;)n(t.shift());return e}function r(n){return n&&n.nodeName&&n.nodeType}function o(n,t){if(n.forEach)return n.forEach(t);for(var e=0;n.length>e;e++)t(n[e],e)}function u(n){return"[object Array]"==Object.prototype.toString.call(n)}var i=n("browser-split"),c=n("class-list"),f=n("data-set");n("html-element"),t.exports=e},{"html-element":1,"browser-split":2,"class-list":3,"data-set":4}],2:[function(n,t){(function(){t.exports=function(n){var t,e=String.prototype.split,r=/()??/.exec("")[1]===n;return t=function(t,o,u){if("[object RegExp]"!==Object.prototype.toString.call(o))return e.call(t,o,u);var i,c,f,a,l=[],s=(o.ignoreCase?"i":"")+(o.multiline?"m":"")+(o.extended?"x":"")+(o.sticky?"y":""),p=0,o=RegExp(o.source,s+"g");for(t+="",r||(i=RegExp("^"+o.source+"$(?!\\s)",s)),u=u===n?-1>>>0:u>>>0;(c=o.exec(t))&&(f=c.index+c[0].length,!(f>p&&(l.push(t.slice(p,c.index)),!r&&c.length>1&&c[0].replace(i,function(){for(var t=1;arguments.length-2>t;t++)arguments[t]===n&&(c[t]=n)}),c.length>1&&c.index<t.length&&Array.prototype.push.apply(l,c.slice(1)),a=c[0].length,p=f,l.length>=u)));)o.lastIndex===c.index&&o.lastIndex++;return p===t.length?(a||!o.test(""))&&l.push(""):l.push(t.slice(p)),l.length>u?l.slice(0,u):l}}()})()},{}],3:[function(n,t){function e(n){function t(n){var t=l();u(t,n)>-1||(t.push(n),s(t))}function e(n){var t=l(),e=u(t,n);-1!==e&&(t.splice(e,1),s(t))}function i(n){return u(l(),n)>-1}function c(n){return i(n)?(e(n),!1):(t(n),!0)}function f(){return n.className}function a(n){var t=l();return t[n]||null}function l(){var t=n.className;return r(t.split(" "),o)}function s(t){var e=t.length;n.className=t.join(" "),v.length=e;for(var r=0;t.length>r;r++)v[r]=t[r];delete t[e]}var p=n.classList;if(p)return p;var v={add:t,remove:e,contains:i,toggle:c,toString:f,length:0,item:a};return v}function r(n,t){for(var e=[],r=0;n.length>r;r++)t(n[r])&&e.push(n[r]);return e}function o(n){return!!n}var u=n("indexof");t.exports=e},{indexof:5}],4:[function(n,t){function e(n){if(n.dataset)return n.dataset;var t=i.get(n);return t||(t=r(n),i.set(n,t)),t}function r(n){var t=n.attributes,e={};if(null===t||void 0===t)return e;for(var r=0;t.length>r;r++){var o=t[r];"data-"===o.name.substr(0,5)&&(e[o.name.substr(5)]=o.value)}return e}var o=n("weakmap"),u=n("individual"),i=u("__DATA_SET_WEAKMAP",o());t.exports=e},{weakmap:6,individual:7}],6:[function(n,t,e){(function(){void function(n,r,o){function u(n,t,e){return"function"==typeof t&&(e=t,t=i(e).replace(/_$/,"")),a(n,t,{configurable:!0,writable:!0,value:e})}function i(n){return"function"!=typeof n?"":"name"in n?n.name:l.call(n).match(v)[1]}function c(n){function t(t,r){return r||2===arguments.length?e.set(t,r):(r=e.get(t),r===o&&(r=n(t),e.set(t,r))),r}var e=new h;return n||(n=g),t}var f=Object.getOwnPropertyNames,a=Object.defineProperty,l=Function.prototype.toString,s=Object.create,p=Object.prototype.hasOwnProperty,v=/^\n?function\s?(\w*)?_?\(/,d=function(){function n(){var n=i(),r={};this.unlock=function(o){var u=l(o);if(p.call(u,n))return u[n](r);var i=s(null,t);return a(u,n,{value:Function("s","l",e)(r,i)}),i}}var t={value:{writable:!0,value:o}},e="return function(k){if(k===s)return l}",r=s(null),i=function(){var n=Math.random().toString(36).slice(2);return n in r?i():r[n]=n},c=i(),l=function(n){if(p.call(n,c))return n[c];if(!Object.isExtensible(n))throw new TypeError("Object must be extensible");var t=s(null);return a(n,c,{value:t}),t};return u(Object,function(n){var t=f(n);return p.call(n,c)&&t.splice(t.indexOf(c),1),t}),u(n.prototype,function(n){return this.unlock(n).value}),u(n.prototype,function(n,t){this.unlock(n).value=t}),n}(),h=function(t){function e(t){return this===n||null==this||this===e.prototype?new e(t):(v(this,new d),g(this,t),o)}function c(n){p(n);var t=h(this).get(n);return t===r?o:t}function f(n,t){p(n),h(this).set(n,t===o?r:t)}function a(n){return p(n),h(this).get(n)!==o}function l(n){p(n);var t=h(this),e=t.get(n)!==o;return t.set(n,o),e}function s(){return h(this),"[object WeakMap]"}var p=function(n){if(null==n||"object"!=typeof n&&"function"!=typeof n)throw new TypeError("Invalid WeakMap key")},v=function(n,e){var r=t.unlock(n);if(r.value)throw new TypeError("Object is already a WeakMap");r.value=e},h=function(n){var e=t.unlock(n).value;if(!e)throw new TypeError("WeakMap is not generic");return e},g=function(n,t){null!==t&&"object"==typeof t&&"function"==typeof t.forEach&&t.forEach(function(e,r){e instanceof Array&&2===e.length&&f.call(n,t[r][0],t[r][1])})};try{var y=("return "+l).replace("e_","\\u0065"),b=Function("unwrap","validate",y)(h,p)}catch(x){var b=l}var y=(""+Object).split("Object"),m=function s(){return y[0]+i(this)+y[1]};u(m,m);var w={__proto__:[]}instanceof Array?function(n){n.__proto__=m}:function(n){u(n,m)};return w(e),[s,c,f,a,b].forEach(function(n){u(e.prototype,n),w(n)}),e}(new d),g=Object.create?function(){return Object.create(null)}:function(){return{}};t!==o?t.exports=h:e!==o?e.WeakMap=h:"WeakMap"in n||(n.WeakMap=h),h.createStorage=c,n.WeakMap&&(n.WeakMap.createStorage=c)}((0,eval)("this"))})()},{}],5:[function(n,t){var e=[].indexOf;t.exports=function(n,t){if(e)return n.indexOf(t);for(var r=0;n.length>r;++r)if(n[r]===t)return r;return-1}},{}],7:[function(n,t){(function(){function e(n,t){return r[n]?r[n]:(Object.defineProperty(r,n,{value:t,configurable:!0}),t)}var r=n("global");t.exports=e})()},{global:8}],8:[function(n,t){(function(n){n!==void 0?t.exports=n:"undefined"!=typeof window&&(t.exports=window)})(self)},{}]},{},[]);var o=require("observable"),h=require("hyperscript"),field=h("input",{type:"text"});value=o.input(field),value(function(n){console.log("changed to",n)}),setTimeout(function(){value("hello")},1e3),document.body.appendChild(field);
<style type='text/css'>html, body { margin: 0; padding: 0; border: 0; }
body, html { height: 100%; width: 100%; }</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.