Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zinovyev/rack-refresher
Rack middleware for authomatic page refresh
https://github.com/zinovyev/rack-refresher
Last synced: 1 day ago
JSON representation
Rack middleware for authomatic page refresh
- Host: GitHub
- URL: https://github.com/zinovyev/rack-refresher
- Owner: zinovyev
- License: mit
- Created: 2018-05-30T08:04:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-30T10:05:12.000Z (over 6 years ago)
- Last Synced: 2024-04-25T13:02:18.844Z (8 months ago)
- Language: Ruby
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rack-refresher
Rack middleware for authomatic page refresh
# About
Refresh the content of your page with a given interval
# Installation
```bash
gem install rack-refresher
```
# Set Up And Configuration
Add the middleware inclusion to the `config.ru` file (before the `run Application` directive):
```ruby
require "rack-refresher"
use Rack::Refresher do |config|
config.ajax = true
config.delay = 1000
end```
**Configuration options**:
* `config.ajax = true` (Default: `false`) Refresh only the `` tag of the page in background via AJAX. The page will be fully reloaded if this option is not set;
* `config.delay = 1000` (Default: `5000`, alias: `config.interval`) Refresh interval defined in milliseconds. 1000 milliseconds == 1 second;
The middleware can be included several times. For example the following code will create 2 refreshers: the first one will refresh the page every 5 seconds via AJAX and the second one will refresh the page every 5 minutes via reload:
```ruby
require "rack-refresher"
use Rack::Refresher do |config|
config.ajax = true
config.delay = 5000 # Every 5 seconds
enduse Rack::Refresher do |config|
config.delay = 300_000 # Every 5 minutes
end```