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
beyondeye authored and daely committed Nov 10, 2016
1 parent ca51372 commit 487f9a7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions reduks/src/main/kotlin/com/beyondeye/reduks/Store.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ interface Store<S> {

}

/**
* allow to use direct call on dispatcher function reference 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)
}

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

0 comments on commit 487f9a7

Please sign in to comment.