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

Statements: 91.3% (42 / 46)      Branches: 63.64% (14 / 22)      Functions: 100% (8 / 8)      Lines: 94.74% (36 / 38)      Ignored: none     

All files » RxJS/dist/cjs/schedulers/ » ImmediateAction.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    1   1   81   1   1   1   1 1   1 81   81 81 81     1 190     190 190 190 190 190     1 206     206     1 59 59 59 59 59 59 59 3   59     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 _Subscription2 = require('../Subscription');
 
var _Subscription3 = _interopRequireDefault(_Subscription2);
 
var ImmediateAction = (function (_Subscription) {
    _inherits(ImmediateAction, _Subscription);
 
    function ImmediateAction(scheduler, work) {
        _classCallCheck(this, ImmediateAction);
 
        _Subscription.call(this);
        this.scheduler = scheduler;
        this.work = work;
    }
 
    ImmediateAction.prototype.schedule = function schedule(state) {
        Iif (this.isUnsubscribed) {
            return this;
        }
        this.state = state;
        var scheduler = this.scheduler;
        scheduler.actions.push(this);
        scheduler.flush();
        return this;
    };
 
    ImmediateAction.prototype.execute = function execute() {
        Iif (this.isUnsubscribed) {
            throw new Error('How did did we execute a canceled Action?');
        }
        this.work(this.state);
    };
 
    ImmediateAction.prototype.unsubscribe = function unsubscribe() {
        var scheduler = this.scheduler;
        var actions = scheduler.actions;
        var index = actions.indexOf(this);
        this.work = void 0;
        this.state = void 0;
        this.scheduler = void 0;
        if (index !== -1) {
            actions.splice(index, 1);
        }
        _Subscription.prototype.unsubscribe.call(this);
    };
 
    return ImmediateAction;
})(_Subscription3['default']);
 
exports['default'] = ImmediateAction;
module.exports = exports['default'];