Code coverage report for RxJS/dist/cjs/schedulers/NextTickAction.js

Statements: 89.36% (42 / 47)      Branches: 58.33% (14 / 24)      Functions: 100% (8 / 8)      Lines: 92.31% (36 / 39)      Ignored: none     

All files » RxJS/dist/cjs/schedulers/ » NextTickAction.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64    1   1   1   1   1   1   1   1 1   1 1   1     1 1   1     1 1 1 1 1 1 1 1 1     1     1 1 1 1 1 1 1 1             1     1 1
'use strict';
 
exports.__esModule = true;
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
 
function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
 
function _inherits(subClass, superClass) { Iif (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); Eif (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
 
var _utilImmediate = require('../util/Immediate');
 
var _ImmediateAction2 = require('./ImmediateAction');
 
var _ImmediateAction3 = _interopRequireDefault(_ImmediateAction2);
 
var NextTickAction = (function (_ImmediateAction) {
    _inherits(NextTickAction, _ImmediateAction);
 
    function NextTickAction() {
        _classCallCheck(this, NextTickAction);
 
        _ImmediateAction.apply(this, arguments);
    }
 
    NextTickAction.prototype.schedule = function schedule(state) {
        var _this = this;
 
        Iif (this.isUnsubscribed) {
            return this;
        }
        this.state = state;
        var scheduler = this.scheduler;
        scheduler.actions.push(this);
        Eif (!scheduler.scheduled) {
            scheduler.scheduled = true;
            this.id = _utilImmediate.Immediate.setImmediate(function () {
                _this.id = void 0;
                _this.scheduler.scheduled = false;
                _this.scheduler.flush();
            });
        }
        return this;
    };
 
    NextTickAction.prototype.unsubscribe = function unsubscribe() {
        var id = this.id;
        var scheduler = this.scheduler;
        _ImmediateAction.prototype.unsubscribe.call(this);
        Eif (scheduler.actions.length === 0) {
            scheduler.active = false;
            scheduler.scheduled = false;
            Iif (id) {
                this.id = void 0;
                _utilImmediate.Immediate.clearImmediate(id);
            }
        }
    };
 
    return NextTickAction;
})(_ImmediateAction3['default']);
 
exports['default'] = NextTickAction;
module.exports = exports['default'];