MCPcopy
hub / github.com/redux-loop/redux-loop / delay

Function delay

src/cmd.js:314–343  ·  view source on GitHub ↗
(nestedCmd, delayMs, options, cmdType, funcName)

Source from the content-addressed store, hash-verified

312}
313
314function delay(nestedCmd, delayMs, options, cmdType, funcName) {
315 if (process.env.NODE_ENV !== 'production') {
316 throwInvariant(
317 isCmd(nestedCmd),
318 `${funcName}: first argument must be another Cmd`
319 );
320 throwInvariant(
321 typeof delayMs === 'number',
322 `${funcName}: second argument must be a number`
323 );
324 throwInvariant(
325 typeof options === 'object',
326 `${funcName}: third argument must be an options object`
327 );
328 throwInvariant(
329 options.scheduledActionCreator === undefined ||
330 typeof options.scheduledActionCreator === 'function',
331 `${funcName}: scheduledActionCreator option must be a function if specified`
332 );
333 }
334
335 return Object.freeze({
336 [isCmdSymbol]: true,
337 type: cmdType,
338 nestedCmd,
339 delayMs,
340 scheduledActionCreator: options.scheduledActionCreator,
341 simulate: simulateDelay,
342 });
343}
344
345function simulateDelay(timerId, nestedSimulation) {
346 let result = this.nestedCmd.simulate(nestedSimulation);

Callers 2

setTimeoutCmdFunction · 0.70
setIntervalCmdFunction · 0.70

Calls 2

throwInvariantFunction · 0.90
isCmdFunction · 0.85

Tested by

no test coverage detected