UNPKG

rxjs6-wx

Version:

Based on Rx.js for Weixin miniprogram

1 lines 1.19 kB
"use strict";function _typeof(o){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o})(o)}var Rx=require("./rxjs"),ob={Rx:{},fromEvent:function(o,n){var t=new Rx.Subject;return o[n]=function(o){t.next(o)},t}};for(var p in Rx)ob.Rx[p]=Rx[p];var cbObj2Obs=function(r,c,o){return Rx.Observable.create(function(n){if("object"===_typeof(r)||void 0===r){var t=Object.assign({},r),o=new Promise(function(o,n){t.success=function(){o.apply(void 0,arguments)},t.fail=function(o){return n(o)}}),e=c.call(null,t)||{};o.then(function(o){n.next(Object.assign(e,o)),n.complete()},function(o){n.error(o,e),n.complete()})}else n.next(c.call(null,r))})},_loop=function(r){switch(_typeof(wx[r])){case"object":ob[r]=Object.assign(wx[r]);break;case"function":/Sync$/.test(r)?ob[r]=function(){for(var o,n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];return Rx.Observable.of((o=wx[r]).call.apply(o,[null].concat(t)))}:ob[r]=function(o){return cbObj2Obs(o,wx[r])};break;default:ob[r]=wx[r]}};for(var _p in wx)_loop(_p);module.exports=ob;