2.8.0 • Published 6 months ago

backburner.js v2.8.0

Weekly downloads
618
License
MIT
Repository
github
Last release
6 months ago

backburner.js Build Status

A rewrite of the Ember.js run loop as a generic microlibrary.

TL;DR

A priority queue that will efficiently batch, order, reorder and process work; done via scheduling work on specific queues.

API

Constructor

ConstructorDescription
new Backburner()instantiate a Backburner instance with an array of queue names

Instance methods

MethodDescription
Backburner#runexecute the passed function and flush any deferred actions
Backburner#deferdefer the passed function to run inside the specified queue
Backburner#deferOncedefer the passed function to run inside the specified queue, only execute it once
Backburner#setTimeoutexecute the passed function in a specified amount of time
Backburner#debounceexecute the passed function in a specified amount of time, reset timer upon additional calls
Backburner#throttlerate-limit the passed function for a specified amount of time
Backburner#cancelcancel a deferOnce, setTimeout, debounce or throttle
Backburner#onAdd an event callback. Supports the following events: begin - Fires whenever the runloop begins. Callbacks are passed the current instance and the previous instance.end - Fires whenever the runloop ends. Callbacks are passed the current instance and the next instance.
Backburner#offRemoves an event callback
Backburner#joinJoin the passed method with an existing queue and execute immediately, if there isn't one use Backburner#run
Backburner#getDebugInfoReturns debug information for counters, timers and queues, which includes surfacing the stack trace information for the respective calls

Alias

AliasDescription
Backburner#schedulesame as defer
Backburner#scheduleOncesame as deferOnce
Backburner#latersame as setTimeout

Example usage

The following code will only cause a single DOM manipulation:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Backburner demo</title>
  </head>

  <body>
    <div id="name"></div>

    <script type="module">
      import Backburner from './dist/es6/backburner.js'

      var backburner = new Backburner(['render']),
        person = {name: 'Erik'};

      function updateName() {
        document.querySelector('#name').innerHTML = person.name;
      }

      function setName(name) {
        person.name = name;
        backburner.deferOnce('render', updateName);
      }

      backburner.run(function() {
        setName('Kris');
        setName('Tom');
        setName('Yehuda');
      });
    </script>
  </body>
</html>
2.8.0

6 months ago

2.7.0

3 years ago

2.6.0

5 years ago

2.5.0

5 years ago

2.4.2

5 years ago

2.4.1

6 years ago

2.4.0

6 years ago

2.3.1

6 years ago

2.3.0

6 years ago

2.2.2

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

1.3.5

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

1.3.4

6 years ago

2.0.0

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.3

6 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.4.0

7 years ago

0.3.1

8 years ago

0.3.0

8 years ago