How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • import { queueScheduler } from 'rxjs';
     
    queueScheduler.schedule(function(state) {
      if (state !== 0) {
        console.log('before', state);
        this.schedule(state - 1); // `this` references currently executing Action,
                                  // which we reschedule with new state
        console.log('after', state);
      }
    }, 0, 3);
     
    // In scheduler that runs recursively, you would expect:
    // "before", 3
    // "before", 2
    // "before", 1
    // "after", 1
    // "after", 2
    // "after", 3
     
    // But with queue it logs:
    // "before", 3
    // "after", 3
    // "before", 2
    // "after", 2
    // "before", 1
    // "after", 1
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">const</span> queueScheduler<span class="token operator">:</span> QueueScheduler <span class="token keyword">import</span> queueScheduler</code><div class="typing-tooltip-markup">Queue Scheduler<br><br><span class="informal">Put every next task on a queue, instead of executing it immediately</span><br><br><code>queue</code> scheduler, when used with delay, behaves the same as {@link asyncScheduler } scheduler.<br><br>When used without delay, it schedules given task synchronously - executes it right when it is scheduled. However when called recursively, that is when inside the scheduled task, another task is scheduled with queue scheduler, instead of executing immediately as well, that task will be put on a queue and wait for current one to finish.<br><br>This means that when you execute task with <code>queue</code> scheduler, you are sure it will end before any other task scheduled with that scheduler will start.<h2>Examples</h2>Schedule recursively first, then do something <pre class="code ts"><code class="language-ts">import { queueScheduler } from 'rxjs'; queueScheduler.schedule(() =&gt; { queueScheduler.schedule(() =&gt; console.log('second')); // will not happen now, but will be put on a queue console.log('first'); }); // Logs: // &quot;first&quot; // &quot;second&quot;</code></pre><br><br>Reschedule itself recursively <pre class="code ts"><code class="language-ts">import { queueScheduler } from 'rxjs'; queueScheduler.schedule(function(state) { if (state !== 0) { console.log('before', state); this.schedule(state - 1); // `this` references currently executing Action, // which we reschedule with new state console.log('after', state); } }, 0, 3); // In scheduler that runs recursively, you would expect: // &quot;before&quot;, 3 // &quot;before&quot;, 2 // &quot;before&quot;, 1 // &quot;after&quot;, 1 // &quot;after&quot;, 2 // &quot;after&quot;, 3 // But with queue it logs: // &quot;before&quot;, 3 // &quot;after&quot;, 3 // &quot;before&quot;, 2 // &quot;after&quot;, 2 // &quot;before&quot;, 1 // &quot;after&quot;, 1</code></pre></div></pre>
    Docs
    0
  • import { queueScheduler } from 'rxjs';
    
    queueScheduler.schedule(() => {
      queueScheduler.schedule(() => console.log('second')); // will not happen now, but will be put on a queue
    
      console.log('first');
    });
    
    // Logs:
    // "first"
    // "second"
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">const</span> queueScheduler<span class="token operator">:</span> QueueScheduler <span class="token keyword">import</span> queueScheduler</code><div class="typing-tooltip-markup">Queue Scheduler<br><br><span class="informal">Put every next task on a queue, instead of executing it immediately</span><br><br><code>queue</code> scheduler, when used with delay, behaves the same as {@link asyncScheduler } scheduler.<br><br>When used without delay, it schedules given task synchronously - executes it right when it is scheduled. However when called recursively, that is when inside the scheduled task, another task is scheduled with queue scheduler, instead of executing immediately as well, that task will be put on a queue and wait for current one to finish.<br><br>This means that when you execute task with <code>queue</code> scheduler, you are sure it will end before any other task scheduled with that scheduler will start.<h2>Examples</h2>Schedule recursively first, then do something <pre class="code ts"><code class="language-ts">import { queueScheduler } from 'rxjs'; queueScheduler.schedule(() =&gt; { queueScheduler.schedule(() =&gt; console.log('second')); // will not happen now, but will be put on a queue console.log('first'); }); // Logs: // &quot;first&quot; // &quot;second&quot;</code></pre><br><br>Reschedule itself recursively <pre class="code ts"><code class="language-ts">import { queueScheduler } from 'rxjs'; queueScheduler.schedule(function(state) { if (state !== 0) { console.log('before', state); this.schedule(state - 1); // `this` references currently executing Action, // which we reschedule with new state console.log('after', state); } }, 0, 3); // In scheduler that runs recursively, you would expect: // &quot;before&quot;, 3 // &quot;before&quot;, 2 // &quot;before&quot;, 1 // &quot;after&quot;, 1 // &quot;after&quot;, 2 // &quot;after&quot;, 3 // But with queue it logs: // &quot;before&quot;, 3 // &quot;after&quot;, 3 // &quot;before&quot;, 2 // &quot;after&quot;, 2 // &quot;before&quot;, 1 // &quot;after&quot;, 1</code></pre></div></pre>
    Docs
    0
  • import { asapScheduler, asyncScheduler } from 'rxjs';
    
    asyncScheduler.schedule(() => console.log('async')); // scheduling 'async' first...
    asapScheduler.schedule(() => console.log('asap'));
    
    // Logs:
    // "asap"
    // "async"
    // ... but 'asap' goes first!
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">const</span> asapScheduler<span class="token operator">:</span> AsapScheduler <span class="token keyword">import</span> asapScheduler</code><div class="typing-tooltip-markup">Asap Scheduler<br><br><span class="informal">Perform task as fast as it can be performed asynchronously</span><br><br><code>asap</code> scheduler behaves the same as {@link asyncScheduler } scheduler when you use it to delay task in time. If however you set delay to <code>0</code>, <code>asap</code> will wait for current synchronously executing code to end and then it will try to execute given task as fast as possible.<br><br><code>asap</code> scheduler will do its best to minimize time between end of currently executing code and start of scheduled task. This makes it best candidate for performing so called "deferring". Traditionally this was achieved by calling <code>setTimeout(deferredTask, 0)</code>, but that technique involves some (although minimal) unwanted delay.<br><br>Note that using <code>asap</code> scheduler does not necessarily mean that your task will be first to process after currently executing code. In particular, if some task was also scheduled with <code>asap</code> before, that task will execute first. That being said, if you need to schedule task asynchronously, but as soon as possible, <code>asap</code> scheduler is your best bet.<h2>Example</h2>Compare async and asap scheduler< <pre class="code ts"><code class="language-ts">import { asapScheduler, asyncScheduler } from 'rxjs'; asyncScheduler.schedule(() =&gt; console.log('async')); // scheduling 'async' first... asapScheduler.schedule(() =&gt; console.log('asap')); // Logs: // &quot;asap&quot; // &quot;async&quot; // ... but 'asap' goes first!</code></pre></div></pre>
    Docs
    0
  • import { asyncScheduler } from 'rxjs';
     
    function task(state) {
      console.log(state);
      this.schedule(state + 1, 1000); // `this` references currently executing Action,
                                      // which we reschedule with new state and delay
    }
     
    asyncScheduler.schedule(task, 3000, 0);
     
    // Logs:
    // 0 after 3s
    // 1 after 4s
    // 2 after 5s
    // 3 after 6s
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">const</span> asyncScheduler<span class="token operator">:</span> AsyncScheduler <span class="token keyword">import</span> asyncScheduler</code><div class="typing-tooltip-markup">Async Scheduler<br><br><span class="informal">Schedule task as if you used setTimeout(task, duration)</span><br><br><code>async</code> scheduler schedules tasks asynchronously, by putting them on the JavaScript event loop queue. It is best used to delay tasks in time or to schedule tasks repeating in intervals.<br><br>If you just want to "defer" task, that is to perform it right after currently executing synchronous code ends (commonly achieved by <code>setTimeout(deferredTask, 0)</code>), better choice will be the {@link asapScheduler } scheduler.<h2>Examples</h2>Use async scheduler to delay task <pre class="code ts"><code class="language-ts">import { asyncScheduler } from 'rxjs'; const task = () =&gt; console.log('it works!'); asyncScheduler.schedule(task, 2000); // After 2 seconds logs: // &quot;it works!&quot;</code></pre><br><br>Use async scheduler to repeat task in intervals <pre class="code ts"><code class="language-ts">import { asyncScheduler } from 'rxjs'; function task(state) { console.log(state); this.schedule(state + 1, 1000); // `this` references currently executing Action, // which we reschedule with new state and delay } asyncScheduler.schedule(task, 3000, 0); // Logs: // 0 after 3s // 1 after 4s // 2 after 5s // 3 after 6s</code></pre></div></pre>
    Docs
    0
  • import { asyncScheduler } from 'rxjs';
    
    const task = () => console.log('it works!');
    
    asyncScheduler.schedule(task, 2000);
    
    // After 2 seconds logs:
    // "it works!"
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">const</span> asyncScheduler<span class="token operator">:</span> AsyncScheduler <span class="token keyword">import</span> asyncScheduler</code><div class="typing-tooltip-markup">Async Scheduler<br><br><span class="informal">Schedule task as if you used setTimeout(task, duration)</span><br><br><code>async</code> scheduler schedules tasks asynchronously, by putting them on the JavaScript event loop queue. It is best used to delay tasks in time or to schedule tasks repeating in intervals.<br><br>If you just want to "defer" task, that is to perform it right after currently executing synchronous code ends (commonly achieved by <code>setTimeout(deferredTask, 0)</code>), better choice will be the {@link asapScheduler } scheduler.<h2>Examples</h2>Use async scheduler to delay task <pre class="code ts"><code class="language-ts">import { asyncScheduler } from 'rxjs'; const task = () =&gt; console.log('it works!'); asyncScheduler.schedule(task, 2000); // After 2 seconds logs: // &quot;it works!&quot;</code></pre><br><br>Use async scheduler to repeat task in intervals <pre class="code ts"><code class="language-ts">import { asyncScheduler } from 'rxjs'; function task(state) { console.log(state); this.schedule(state + 1, 1000); // `this` references currently executing Action, // which we reschedule with new state and delay } asyncScheduler.schedule(task, 3000, 0); // Logs: // 0 after 3s // 1 after 4s // 2 after 5s // 3 after 6s</code></pre></div></pre>
    Docs
    0
  • const proxyObserver = {
      next(val) {
        asyncScheduler.schedule(
          (x) => finalObserver.next(x),
          0 /* delay */,
          val /* will be the x for the function above */
        );
      },
    
      // ...
    }
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">const</span> proxyObserver<span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token function">next</span><span class="token punctuation">(</span>val<span class="token operator">:</span> <span class="token builtin">any</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token keyword">void</span><span class="token punctuation">;</span> <span class="token punctuation">}</span></code></pre>
    Docs
    0
  • import { asapScheduler, asyncScheduler } from 'rxjs';
    
    asyncScheduler.schedule(() => console.log('async')); // scheduling 'async' first...
    asapScheduler.schedule(() => console.log('asap'));
    
    // Logs:
    // "asap"
    // "async"
    // ... but 'asap' goes first!
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">const</span> asapScheduler<span class="token operator">:</span> AsapScheduler <span class="token keyword">import</span> asapScheduler</code><div class="typing-tooltip-markup">Asap Scheduler<br><br><span class="informal">Perform task as fast as it can be performed asynchronously</span><br><br><code>asap</code> scheduler behaves the same as {@link asyncScheduler } scheduler when you use it to delay task in time. If however you set delay to <code>0</code>, <code>asap</code> will wait for current synchronously executing code to end and then it will try to execute given task as fast as possible.<br><br><code>asap</code> scheduler will do its best to minimize time between end of currently executing code and start of scheduled task. This makes it best candidate for performing so called "deferring". Traditionally this was achieved by calling <code>setTimeout(deferredTask, 0)</code>, but that technique involves some (although minimal) unwanted delay.<br><br>Note that using <code>asap</code> scheduler does not necessarily mean that your task will be first to process after currently executing code. In particular, if some task was also scheduled with <code>asap</code> before, that task will execute first. That being said, if you need to schedule task asynchronously, but as soon as possible, <code>asap</code> scheduler is your best bet.<h2>Example</h2>Compare async and asap scheduler< <pre class="code ts"><code class="language-ts">import { asapScheduler, asyncScheduler } from 'rxjs'; asyncScheduler.schedule(() =&gt; console.log('async')); // scheduling 'async' first... asapScheduler.schedule(() =&gt; console.log('asap')); // Logs: // &quot;asap&quot; // &quot;async&quot; // ... but 'asap' goes first!</code></pre></div></pre>
    Docs
    0
  • module.exports = function visitQueues (inventory, template) {
      
      //...
    inv.queues.forEach(queue => {
        let { config } = queue
        let { timeout, fifo } = config
    
        let name = toLogicalID(queue.name)
        let queueLambda = `${name}QueueLambda`
        let queueEvent = `${name}QueueEvent`
        let queueQueue = `${name}Queue`
    
        // Create the Lambda
        
        //...
    })
    
      
    
      //...
    }
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">module</span> <span class="token keyword">export</span><span class="token operator">=</span> <span class="token punctuation">(</span>property<span class="token punctuation">)</span> <span class="token keyword">export</span><span class="token operator">=</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">inventory<span class="token operator">:</span> any<span class="token punctuation">,</span> template<span class="token operator">:</span> any</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token builtin">any</span></code><div class="typing-tooltip-markup">Visit arc.queues and merge in AWS::Serverless resources</div></pre>
    /architect/package apache-2.0
    0
  • var cron = require('node-cron');
    
    var task = cron.schedule('* * * * *', () =>  {
      console.log('will execute every minute until stopped');
    });
    
    task.stop();
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">import</span> cron</code></pre>
    Docs
    0
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples