Skip to content

Commit

Permalink
Merge branch 'release/v3.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mplatvoet committed Mar 17, 2016
2 parents acde483 + 03620c3 commit b294bfa
Show file tree
Hide file tree
Showing 18 changed files with 200 additions and 143 deletions.
31 changes: 14 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ task { "world" } and task { "Hello" } success {
Please refer to the [Kovenant](http://kovenant.komponents.nl) site for API usage and more.

## Getting started
Build against Kotlin: `1.0.0`.
Build against Kotlin: `1.0.1`.
Source and target compatibility is `1.6`

###Gradle
```groovy
dependencies {
compile 'nl.komponents.kovenant:kovenant:3.1.0'
compile 'nl.komponents.kovenant:kovenant:3.2.0'
}
```

Expand All @@ -32,15 +32,15 @@ dependencies {
<dependency>
<groupId>nl.komponents.kovenant</groupId>
<artifactId>kovenant</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
</dependency>
```

###Android Demo app
Checkout the [Android Demo App on Github](https://github.com/mplatvoet/kovenant-android-demo).

###Artifacts
Kovenant has been structured in sub projects so you can cherry pick what you need.
Kovenant has been structured in sub projects so you can cherry pick what you need.

|artifact |description |
|--------------------|---------------------------------------------------------------------------------------------------|
Expand All @@ -50,23 +50,20 @@ Kovenant has been structured in sub projects so you can cherry pick what you nee
|kovenant-jvm |Support for converting between Executors and Dispatchers |
|kovenant-ui |Support for UI frameworks that need UI work to operate on a specific process |
|kovenant-rx |Add promise support to Rx |
|kovenant-android |Extensions for Android specific needs |
|kovenant-jfx |Extensions for JavaFX specific needs |
|kovenant-disruptor |LMAX Disruptor work queues |
|kovenant-progress |Progress configuration helper |
|kovenant-functional |Functional Programming idiomatic additions |
|kovenant-android |Extensions for Android specific needs |
|kovenant-jfx |Extensions for JavaFX specific needs |
|kovenant-disruptor |LMAX Disruptor work queues |
|kovenant-progress |Progress configuration helper |
|kovenant-functional |Functional Programming idiomatic additions |

##Issues
##Issues
Issues are tracked in [Youtrack](http://issues.komponents.nl/youtrack/issues?q=project%3A+Kovenant)

##Release notes
See [Changelog](http://kovenant.komponents.nl/changelog/) for release notes
See [Changelog](changelog.md) for release notes

##Slack
Join the `#kovenant` channel on [Kotlin Slack](http://kotlinslackin.herokuapp.com).
Join the `#kovenant` channel on [Kotlin Slack](http://kotlinslackin.herokuapp.com).

## Recommended libraries:
Other libraries for Kotlin applications

* [Injekt](https://github.com/kohesive/injekt) - Crazily easy Dependency Injection for Kotlin
* [Fuel](https://github.com/kittinunf/Fuel) - The easiest HTTP networking library in Kotlin for Android.
## More Kotlin libraries
Check out [Awesome Kotlin](https://github.com/JavaBy/awesome-kotlin)
36 changes: 33 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

buildscript {
ext.kotlinVersion = '1.0.0'
ext.kotlinVersion = '1.0.1'
ext.extraConfVersion = '2.2.+'

repositories {
Expand All @@ -33,19 +33,23 @@ buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "com.netflix.nebula:gradle-extra-configurations-plugin:$extraConfVersion"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.5'
}
}

allprojects {
ext {
appVersion = '3.1.0'
appVersion = '3.2.0'
appGroup = 'nl.komponents.kovenant'


junitVersion = '4.12'

sonatypeUsr = project.hasProperty('sonatypeUsername') ? sonatypeUsername : ''
sonatypePwd = project.hasProperty('sonatypePassword') ? sonatypePassword : ''

bintrayUsr = project.hasProperty('bintrayUsername') ? bintrayUsername : ''
bintrayKey = project.hasProperty('bintrayApiKey') ? bintrayApiKey : ''
}
}

Expand All @@ -69,6 +73,7 @@ subprojects {
apply plugin: 'kotlin'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'com.jfrog.bintray'

compileJava {
sourceCompatibility = "1.6"
Expand Down Expand Up @@ -183,12 +188,33 @@ subprojects {

}
}

bintray {
user = bintrayUsr
key = bintrayKey
pkg {
repo = 'komponents'
name = project.name
licenses = ['MIT']
vcsUrl = 'scm:git:[email protected]:mplatvoet/kovenant.git'

version {
name = appVersion
desc = 'n/a'
released = new Date()
}
publicDownloadNumbers = false
configurations = ['archives']
}
publish = true
dryRun = false
}
}

gradle.taskGraph.whenReady { taskGraph ->
def branchName = System.getenv('CIRCLE_BRANCH')?.trim()

if ('master'.equals(branchName) || taskGraph.hasTask(release)) {
if ('master'.equals(branchName) || taskGraph.hasTask(release) || taskGraph.hasTask(bintray)) {
allprojects*.version = appVersion
} else {
allprojects*.version = "$appVersion-SNAPSHOT"
Expand All @@ -206,5 +232,9 @@ task release() {
dependsOn subprojects.uploadArchives
}

task bintray {
dependsOn subprojects.bintrayUpload
}


defaultTasks 'clean', 'jars'
54 changes: 41 additions & 13 deletions docs/docs/api/core_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,14 @@ failed. The work of `then` is executed by the `workerContext`.

---

##Then Use
`thenUse` operates similar to [`then`](#then) except that it takes the output from a previous `Promise` as its input
##ThenApply
`thenApply` operates similar to [`then`](#then) except that it takes the output from a previous `Promise` as its input
as an extension function. The previous example would thus be:

```kt
task {
fib(20)
} thenUse {
} thenApply {
"fib(20) = $this, and fib(21) = (${fib(21)})"
} success {
println(it)
Expand Down Expand Up @@ -237,7 +237,7 @@ val expensiveResource by lazyPromise {
fun main(args: Array<String>) {
println("start program")

expensiveResource thenUse {
expensiveResource thenApply {
"Got [$value]"
} success {
println(it)
Expand Down Expand Up @@ -332,20 +332,48 @@ any (*promises) success { msg ->

##Cancel
Any `Promise` that implements `CancelablePromise` allows itself to be cancelled. By default the promises returned
from [`task`](#task), [`then`](#then) and [`thenUse`](#thenUse) are `CancelablePromise`s.
from [`task`](#task), [`then`](#then) and [`thenApply`](#thenApply) are `CancelablePromise`s.

Cancelling a promises is quite similar to [`Deferred.reject`](#deferred) as it finishes the promises as failed. Thus
the callbacks `fail` and `always` are still executed. Cancel does also try to prevent the promised work from ever being
scheduled. If the promised work is already running it gets [interrupted](https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#interrupt()) (when using default dispatchers).
scheduled. If the promised work is already running it gets [interrupted](https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#interrupt()) (when using default dispatchers).

---
---

##Void
There are those times where just knowing that something has either failed or succeeded is enough information. So for
the ultimate "on a need to know basis" Kovenant provides three methods that hide the results:
##Void
There are those times where just knowing that something has either failed or succeeded is enough information. So for
the ultimate "on a need to know basis" Kovenant provides three methods that hide the results:

* `toVoid()`, creates a `Promise<Unit, Unit>` of an existing `Promise<V, E>`
* `toSuccessVoid()`, creates a `Promise<Unit, E>` of an existing `Promise<V, E>`
* `toFailVoid()`, creates a `Promise<V, Unit>` of an existing `Promise<V, E>`


* `toVoid()`, creates a `Promise<Unit, Unit>` of an existing `Promise<V, E>`
* `toSuccessVoid()`, creates a `Promise<Unit, E>` of an existing `Promise<V, E>`
* `toFailVoid()`, creates a `Promise<V, Unit>` of an existing `Promise<V, E>`
---

##unwrap
Unwraps any nested Promise. By default the returned `Promise` will operate on the same `Context` as its parent
`Promise`, no matter what the `Context` of the nested `Promise` is. If you want the resulting promise to operate on
a different `Context` you can provide one.

Function tries to be as efficient as possible in cases where this or the nested `Promise` is already resolved. This
means that this function might or might not create a new `Promise`, it all depends on the current state.

```kt
val nested = Promise.of(Promise.of(42))
val promise = nested.unwrap()
promise success {
println(it)
}
```

##withContext
Returns a `Promise` operating on the provided `Context`. This function might return the same instance of the `Promise`
or a new one depending whether the `Context` of the `Promise` and the provided `Promise` match.

```kt
val p = Promise.of(42).withContext(Kovenant.context)
```



26 changes: 0 additions & 26 deletions docs/docs/api/functional_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,4 @@ val p = Promise.of(21) apply Promise.of({ x: Int -> x * 2 })
p success { println(it) }
```

---

##unwrap
Unwraps any nested Promise. By default the returned `Promise` will operate on the same `Context` as its parent
`Promise`, no matter what the `Context` of the nested `Promise` is. If you want the resulting promise to operate on
a different `Context` you can provide one.

Function tries to be as efficient as possible in cases where this or the nested `Promise` is already resolved. This
means that this function might or might not create a new `Promise`, it all depends on the current state.

```kt
val nested = Promise.of(Promise.of(42))
val promise = nested.unwrap()
promise success {
println(it)
}
```

##withContext
Returns a `Promise` operating on the provided `Context`. This function might return the same instance of the `Promise`
or a new one depending whether the `Context` of the `Promise` and the provided `Promise` match.

```kt
val p = Promise.of(42).withContext(Kovenant.context)
```


15 changes: 14 additions & 1 deletion docs/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@
Changelog of Kovenant. Complying to [Semantic Versioning](http://semver.org).
Please refer to [roadmap](roadmap.md) for upcoming releases.

##v3.0.0
##v3.2.0

**core**

* [KOV-74](http://issues.komponents.nl/youtrack/issue/KOV-74) Move `unwrap` to core library
* [KOV-75](http://issues.komponents.nl/youtrack/issue/KOV-75) Move `withContext` to core library
* [KOV-76](http://issues.komponents.nl/youtrack/issue/KOV-76) rename `thenUse` to `thenApply`

**general**

* [KOV-77](http://issues.komponents.nl/youtrack/issue/KOV-77) Kotlin 1.0.1


##v3.1.0

**rx**

Expand Down
13 changes: 5 additions & 8 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ Developed with the following [goals](misc/goals.md) in mind.
* **Dependency free**: when not counting kotlin std

## Getting started
Build against Kotlin: `1.0.0`.
Build against Kotlin: `1.0.1`.
Source and target compatibility is `1.6`

###Gradle
```groovy
dependencies {
compile 'nl.komponents.kovenant:kovenant:3.1.0'
compile 'nl.komponents.kovenant:kovenant:3.2.0'
}
```

Expand All @@ -40,7 +40,7 @@ dependencies {
<dependency>
<groupId>nl.komponents.kovenant</groupId>
<artifactId>kovenant</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
</dependency>
```

Expand Down Expand Up @@ -73,8 +73,5 @@ See [Changelog](changelog.md) for release notes
##Slack
Join the `#kovenant` channel on [Kotlin Slack](http://kotlinslackin.herokuapp.com).

## Recommended libraries
Other libraries for Kotlin applications:

* [Injekt](https://github.com/kohesive/injekt) - Crazily easy Dependency Injection for Kotlin
* [Fuel](https://github.com/kittinunf/Fuel) - The easiest HTTP networking library in Kotlin for Android.
## More Kotlin libraries
Check out [Awesome Kotlin](https://github.com/JavaBy/awesome-kotlin)
14 changes: 13 additions & 1 deletion docs/docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@ Input is always welcome.

---

##v3.2.0
##v3.3.0

**expected**

* UI Click handler
* Timeouts on blocking methods

**certain**

* n/a

---

##v4.0.0

**expected**

* Groundwork for JavaScript, core only.

**certain**
Expand Down
29 changes: 29 additions & 0 deletions projects/core/src/main/kotlin/context-api.kt
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,32 @@ fun Kovenant.testMode(failures: (Throwable) -> Unit = { throw it }) {
}
}
}


/**
* Returns a `Promise` operating on the provided `Context`
*
* This function might return the same instance of the `Promise` or a new one depending whether the
* `Context` of the `Promise` and the provided `Promise` match.
*
*
* @param context The `Context` on which the returned promise should operate
* @return the same `Promise` if the `Context` matches, a new promise otherwise with the provided context
*/
fun <V, E> Promise<V, E>.withContext(context: Context): Promise<V, E> {
// Already same context, just return self
if (this.context == context) return this

// avoid using deferred and callbacks if this promise
// is already resolved
if (isDone()) when {
isSuccess() -> return Promise.ofSuccess(get(), context)
isFailure() -> return Promise.ofFail(getError(), context)
}

//okay, the hard way
val deferred = deferred<V, E>(context)
success { deferred resolve it }
fail { deferred reject it }
return deferred.promise
}
Loading

0 comments on commit b294bfa

Please sign in to comment.