Skip to content

Commit 8c803f3

Browse files
Merge pull request #3 from meantrix/develop
Async 0.0.4
2 parents 41cf767 + 39b0e2b commit 8c803f3

File tree

6 files changed

+50
-9
lines changed

6 files changed

+50
-9
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
#CHANGELOG
22

3+
## Async 0.0.4
4+
5+
- `async[R6]` : New param verbose to provides much more
6+
information about the flow of information between the R processes.
7+
8+
### Bug Fixes :
9+
10+
- Error: `"observer error: Error in if (private$interrupted()) {: argument is of length zero\n"`
11+
in async class fixed.
12+
313
## Async 0.0.3
414

515
New routines to save and load async objects as `rds` files ;
@@ -21,7 +31,7 @@ New progress bar with cancel button;
2131
- The package documentation has been rewritten.
2232

2333
### Bugs
24-
- `asyn: get_status` method character(0) error fixed;
34+
- `async: get_status` method character(0) error fixed;
2535

2636

2737

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: async
22
Type: Package
33
Title: Async
4-
Version: 0.0.3
4+
Version: 0.0.4
55
Authors@R:
66
c(person(
77
given = "Igor",

R/async.R

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ async = R6::R6Class(classname = 'async',
3737
private = list(
3838

3939
vars = list(status_file = NULL,
40+
verbose = FALSE,
4041
upper = 100,
4142
lower = 0,
4243
auto.finish = TRUE,
@@ -49,7 +50,11 @@ async = R6::R6Class(classname = 'async',
4950
vm = scan(private$vars$status_file,
5051
what = "character",
5152
sep="\n",quiet = TRUE)
52-
print(vm)
53+
54+
if(private$vars$verbose){
55+
message(paste0("get status: ",vm))
56+
}
57+
5358
vm = try(stringr::str_split(vm,' zzzz ')[[1]])
5459

5560
if(!inherits(vm,'try-error')){
@@ -65,15 +70,22 @@ async = R6::R6Class(classname = 'async',
6570
vm = paste0(value,' zzzz ',msg ,' zzzz ',detail)
6671
write(vm, private$vars$status_file)
6772

73+
if(private$vars$verbose){
74+
message(paste0("set status: ",vm))
75+
}
76+
6877
vm.out = stringr::str_split(vm,' zzzz ')[[1]]
6978
names(vm.out) = c('value','message','detail')
79+
80+
81+
7082
private$vars$vm = vm.out
7183

7284

7385
},
7486

7587
interrupted = function(){
76-
private$get_status()[1] == "7777"
88+
isTRUE(private$get_status()[1] == "7777")
7789
},
7890

7991

@@ -85,7 +97,7 @@ async = R6::R6Class(classname = 'async',
8597

8698
}
8799

88-
if(private$get_status()[1] == as.character(private$vars$upper)
100+
if( isTRUE(private$get_status()[1] == as.character(private$vars$upper))
89101
&& private$vars$auto.finish) {
90102
#unlink(private$vars$status_file)
91103
stop("Process finished")
@@ -163,13 +175,16 @@ async = R6::R6Class(classname = 'async',
163175
#'be interrupted when the progress is equal to the upper value.
164176
#' @param reactive If its true generate a reactive expression
165177
#' is a expression whose result will change over time.
178+
#' @param verbose logical.If its TRUE provides much more
179+
#' information about the flow of information between the R processes.
166180
#' @param msg A single-element character vector;
167181
#' the initial message to be pass between processes.
168182
#' @param detail A single-element character vector;
169183
#' the initial detail message to be pass between processes.
170184
initialize = function(lower, upper,
171185
auto.finish = TRUE,
172186
reactive=TRUE,
187+
verbose = FALSE,
173188
msg,
174189
detail){
175190

@@ -192,6 +207,7 @@ async = R6::R6Class(classname = 'async',
192207
checkmate::expect_numeric(c(lower,upper),lower = 0,upper = 1000)
193208
checkmate::expect_logical(auto.finish,max.len = 1)
194209
checkmate::expect_logical(reactive,max.len = 1)
210+
checkmate::expect_logical(verbose,max.len = 1)
195211
checkmate::expect_character(msg,max.len = 1)
196212
checkmate::expect_character(detail,max.len = 1)
197213

@@ -211,6 +227,7 @@ async = R6::R6Class(classname = 'async',
211227
private$.reactive = reactive
212228
private$rx_trigger = reactiveTrigger()
213229

230+
private$vars$verbose = verbose
214231
private$vars$lower = lower
215232
private$vars$upper = upper
216233
private$vars$auto.finish = auto.finish
@@ -225,7 +242,10 @@ async = R6::R6Class(classname = 'async',
225242
#' the interrupt detail message to be pass between processes.
226243
interrupt = function(msg="process interrupted", detail =""){
227244

228-
args = list(value = 7777, msg = msg, detail ='')
245+
checkmate::expect_character(msg,max.len = 1)
246+
checkmate::expect_character(detail,max.len = 1)
247+
248+
args = list(value = 7777, msg = msg, detail =detail)
229249
do.call(private$set_status, args = args)
230250

231251
if(isTRUE(private$.reactive)){

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
![logo](https://github.com/meantrix/async/blob/develop/inst/header_transparente_colorido.png)
44

55
<!--- These are examples. See https://shields.io for others or to customize this set of shields. You might want to include dependencies, project status and licence info here --->
6-
[![version](https://img.shields.io/badge/version-0.0.3-green.svg)](https://semver.org)
6+
[![version](https://img.shields.io/badge/version-0.0.4-green.svg)](https://semver.org)
77

88

99
async is a `tool` for passing messages between some R processes

examples/progress_bar.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ server <- function(input, output,session) {
1818
N <- 100
1919
reactlog_enable()
2020
asy1 = async$new(reactive=TRUE,auto.finish=FALSE,lower = 0, upper = 100)
21-
asy2 = async$new(reactive = TRUE,auto.finish = FALSE)
21+
asy2 = async$new(reactive = TRUE,auto.finish = FALSE,verbose = T)
2222

2323

2424

man/async.Rd

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)