Skip to content

Commit 8586c42

Browse files
authored
Merge pull request #7 from reduxkotlin/task/sample
Kotlin 1.4 + updates
2 parents 9ab06a3 + 9c0e9e9 commit 8586c42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1435
-693
lines changed

.circleci/config.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish a release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
publish:
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
matrix:
13+
os: [ubuntu-latest, macos-latest, windows-latest]
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- name: Publish Release
19+
env:
20+
SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
21+
SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
22+
GPG_SECRET: ${{ secrets.GPG_SECRET }}
23+
GPG_SIGNING_PASSWORD: ${{ secrets.GPG_SIGNING_PASSWORD }}
24+
run: ./gradlew publish
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Publish snapshot
2+
3+
on:
4+
push:
5+
branches: [ master, feature/*, kotlin-* ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
publish-snapshot:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [macos-latest, windows-latest, ubuntu-latest]
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: Publish macOS artifacts Snapshot
20+
id: publish-macos
21+
if: matrix.os == 'macos-latest'
22+
env:
23+
SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
24+
SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
25+
GPG_SECRET: ${{ secrets.GPG_SECRET }}
26+
GPG_SIGNING_PASSWORD: ${{ secrets.GPG_SIGNING_PASSWORD }}
27+
SNAPSHOT: 'TRUE'
28+
run: ./gradlew publish
29+
30+
- name: Publish windows artifacts Snapshot
31+
id: publish-win
32+
if: matrix.os == 'windows-latest'
33+
env:
34+
SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
35+
SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
36+
GPG_SECRET: ${{ secrets.GPG_SECRET }}
37+
GPG_SIGNING_PASSWORD: ${{ secrets.GPG_SIGNING_PASSWORD }}
38+
SNAPSHOT: 'TRUE'
39+
run: ./gradlew publish
40+
41+
- name: Publish linux artifacts Snapshot
42+
id: publish-linux
43+
if: matrix.os == 'ubuntu-latest'
44+
env:
45+
SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
46+
SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
47+
GPG_SECRET: ${{ secrets.GPG_SECRET }}
48+
GPG_SIGNING_PASSWORD: ${{ secrets.GPG_SIGNING_PASSWORD }}
49+
SNAPSHOT: 'TRUE'
50+
run: ./gradlew publish
51+
52+
- name: Archive reselect publications dir
53+
uses: actions/upload-artifact@v1
54+
with:
55+
name: publications-${{ matrix.os }}
56+
path: reselect/build/publications

.github/workflows/pull_request.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: PR
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- 'docs/**'
7+
- '*.md'
8+
9+
jobs:
10+
ktlint:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Ktlint
17+
uses: "vroy/gha-kotlin-linter@v1"
18+
test:
19+
needs: ktlint
20+
runs-on: ${{ matrix.os }}
21+
strategy:
22+
matrix:
23+
os: [macos-latest, windows-latest, ubuntu-latest]
24+
steps:
25+
- uses: actions/checkout@v2
26+
27+
- name: Test
28+
run: ./gradlew build
29+

README.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,53 @@ Documentation to come.
1818

1919
Example usage:
2020

21+
Subscribe to a single substate:
22+
2123
```
22-
val subscriber: StoreSubscriber = SelectorSubscriberFn<AppState>(store) {
23-
withSingleField({ it.isLoadingItems }) { <-- only called when isLoadingItems changes from previous state.
24-
if (state.isLoadingItems) {
25-
view?.showLoading()
26-
} else {
27-
view?.hideLoading()
28-
}
29-
}
24+
//selecting a substate subscribes to changes. Lambda block will be executed when there is
25+
//a change in value of `isLoading`
26+
val subscriber: StoreSubscriber = store.select({ it.isLoading }) {
27+
loadingIndicator.visibility = if (store.state.isLoading) View.VISIBLE else View.GONE
28+
}
3029
31-
store.subscribe(subscriber)
30+
//invoking subcription unsubscribes. Do this when appropriate for component lifecycle
31+
subscriber()
32+
```
3233

34+
Subscribe to multiple substates:
3335
```
36+
val multiSubscription = store.selectors {
37+
select({ it.isLoading }) {
38+
loadingIndicator.visibility = if (store.state.isLoading) View.VISIBLE else View.GONE
39+
}
40+
select({ it.name }) {
41+
nameTextView.text = store.state.name
42+
}
43+
}
3444
45+
//unsubscribe when appropriate
46+
multiSubscription()
47+
```
3548
__How to add to project:__
3649

50+
Requires Kotlin 1.4.0.
3751
Artifacts are hosted on maven central. For multiplatform, add the following to your shared module:
3852

53+
3954
```
4055
kotlin {
4156
sourceSets {
4257
commonMain { // <--- name may vary on your project
4358
dependencies {
44-
implementation "org.reduxkotlin:redux-kotlin-reselect:0.4.0"
59+
implementation "org.reduxkotlin:redux-kotlin-reselect:0.5.5"
4560
}
4661
}
4762
}
4863
```
4964

5065
For JVM only:
5166
```
52-
implementation "org.reduxkotlin:redux-kotlin-jvm-reselect:0.4.0"
67+
implementation "org.reduxkotlin:redux-kotlin-jvm-reselect:0.5.5"
5368
```
5469

5570
[badge-android]: http://img.shields.io/badge/platform-android-brightgreen.svg?style=flat

build.gradle

Lines changed: 0 additions & 51 deletions
This file was deleted.

build.gradle.kts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
buildscript {
3+
repositories {
4+
google()
5+
mavenCentral()
6+
maven("https://dl.bintray.com/jetbrains/kotlin-native-dependencies")
7+
maven("https://plugins.gradle.org/m2/")
8+
maven("https://oss.sonatype.org/content/repositories/snapshots")
9+
jcenter()
10+
}
11+
12+
dependencies {
13+
classpath(Plugins.kotlin)
14+
classpath(Plugins.dokka)
15+
classpath(Plugins.android)
16+
}
17+
}
18+
19+
plugins {
20+
id("de.fayard.buildSrcVersions") version "0.4.2"
21+
}
22+
23+
allprojects {
24+
repositories {
25+
google()
26+
jcenter()
27+
maven("https://kotlin.bintray.com/kotlinx")
28+
maven("https://oss.sonatype.org/content/repositories/snapshots")
29+
mavenCentral()
30+
}
31+
32+
group = project.properties["GROUP"]!!
33+
version = project.properties["VERSION_NAME"]!!
34+
if (hasProperty("SNAPSHOT") || System.getenv("SNAPSHOT") != null) {
35+
version = "$version-SNAPSHOT"
36+
}
37+
}

buildSrc/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.gradle/
2+
build/

buildSrc/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
repositories {
2+
jcenter()
3+
}
4+
5+
plugins {
6+
`kotlin-dsl`
7+
}

0 commit comments

Comments
 (0)