Download the PHP package jnilla/joomla-request-batcher without Composer
On this page you can find all versions of the php package jnilla/joomla-request-batcher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jnilla/joomla-request-batcher
More information about jnilla/joomla-request-batcher
Files in jnilla/joomla-request-batcher
Package joomla-request-batcher
Short Description Send and process requests in batches
License MIT
Homepage https://github.com/jnilla/joomla-request-batcher
Informations about the package joomla-request-batcher
joomla-request-batcher
Send and process requests in batches.
Send multiple requests in batches to reduce the overhead of sending multiple requests individually.
Installation (Server Side)
Install using Composer:
Load the library using the Composer autoloader:
Installation (Client Side)
This library depends on jQuery. Include the file after jQuery and before your code. Example:
Basic Usage (Client Side)
The request batcher uses the namespace:
Basic configuration:
Add one request to the actual batch
The addRequest
method has a mechanism to prevent duplicated requests.
The batcher does nothing if the actual batch has no requests.
Basic Usage (Server Side)
Declaration:
The process
method process the batch executing a callback for each request in the actual batch.
Example
On the client side we got an script that displays the value of one product (A) every 2 seconds, and the value of another product (B) every 10 seconds.
The abtches are send every 1 seconds, but the requests are added at different interval. You can play with the batch interval and how ofthen they are added to meet your needs. For this example some times nothing is send because the batch is empty, some times the batch has 1 request and some times the batch has 2 requests.
On the server side we can implement a structure like this that resembles a task based controller.
The server response is send automatically after the batch is processed.
As simple as it is.
License
This project is under the MIT License.