Skip to content

Commit

Permalink
added extension function to allow direct call to dispatch function re…
Browse files Browse the repository at this point in the history
…ference even if nullable
  • Loading branch information
daely committed Nov 10, 2016
1 parent 487f9a7 commit a5e109b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions reduks/src/main/kotlin/com/beyondeye/reduks/Store.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ interface Store<S> {

}


/**
* allow to use direct call on dispatcher function reference even if it is nullable
* allow to use direct call on dispatcher function reference: dispatch(action) even if it is nullable
* instead of having to write dispatch?.invoke(action)
*/
operator fun ((action:Any) -> Any)?.invoke(action:Any) {
if(this!=null) this.invoke(action)
}
operator fun ((action:Any) -> Any)?.invoke(action:Any):Any? =
if(this!=null) this.invoke(action) else null

/**
* extension method for directly provide a lambda as argument for store subscribe
Expand Down

0 comments on commit a5e109b

Please sign in to comment.