https://github.com/gaborcsardi/after
Run Code in the Background
https://github.com/gaborcsardi/after
Last synced: 26 days ago
JSON representation
Run Code in the Background
- Host: GitHub
- URL: https://github.com/gaborcsardi/after
- Owner: gaborcsardi
- Created: 2016-06-14T22:33:49.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-07-09T16:13:42.000Z (almost 9 years ago)
- Last Synced: 2024-08-13T07:13:28.273Z (8 months ago)
- Language: R
- Size: 14.6 KB
- Stars: 14
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- jimsghstars - gaborcsardi/after - Run Code in the Background (R)
README
# after
> Run Code in the Background
[](https://travis-ci.org/gaborcsardi/after)
[](https://ci.appveyor.com/project/gaborcsardi/after)
[](http://www.r-pkg.org/pkg/after)
[](http://www.r-pkg.org/pkg/after)
[](https://codecov.io/github/gaborcsardi/after?branch=master)Run an R function in the background, possibly after a delay. The current
version uses the Tcl event loop and was ported from the 'tcltk2' package.## Installation
```r
source("https://install-github.me/gaborcsardi/after")
```## Usage
```r
library(after)
```Run a function five seconds later:
```r
after(5000, function() cat("Here I am!\n"))
```Call a function in a package. It is good practice to create an
anonymous function for this:```r
after(5000, function() utils::alarm())
```Run a function every three seconds:
```r
id <- after(3000, function() cat("Still here!\n"), redo = Inf)
Sys.sleep(10)
``````
Still here!
Still here!
Still here!
```Cancel it:
```r
after$cancel(id)
```## License
LGPL-3 © Gábor Csárdi