UNPKG

redux-saga-takex

Version:

A powerful take effect accepting RegExp instead of listing action types.

53 lines (41 loc) 1.07 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = takex; var _effects = require('redux-saga/effects'); var _marked = [takexSaga].map(regeneratorRuntime.mark); function takexSaga(pattern) { var action; return regeneratorRuntime.wrap(function takexSaga$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: action = void 0; case 1: if (!true) { _context.next = 9; break; } _context.next = 4; return (0, _effects.take)('*'); case 4: action = _context.sent; if (!(action && pattern.test(action.type))) { _context.next = 7; break; } return _context.abrupt('return', action); case 7: _context.next = 1; break; case 9: case 'end': return _context.stop(); } } }, _marked[0], this); } function takex(pattern) { return (0, _effects.call)(takexSaga, pattern); }