Skip to content

Commit

Permalink
Merge pull request #6 from 1tontech/master
Browse files Browse the repository at this point in the history
  • Loading branch information
shadskii committed Aug 21, 2018
2 parents 7c89be0 + b0df0ab commit 047d3d3
Show file tree
Hide file tree
Showing 22 changed files with 470 additions and 97 deletions.
27 changes: 26 additions & 1 deletion .gitignore
@@ -1 +1,26 @@
gradle.properties
# Gradle
.gradle/

# IntelliJ
.idea/*
.idea/*/
# Required for code settings & persisting copyright settings
!.idea/codeStyleSettings.xml
!.idea/copyright/
out/
build/
*.iml
**/*.iml
*.ipl
**/*.ipl
*.iwl
**/*.iwl

# Eclipse
target/
.project
.classpath

# Misc
*.log
*.*~
42 changes: 21 additions & 21 deletions .idea/codeStyleSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions .idea/compiler.xml

This file was deleted.

10 changes: 5 additions & 5 deletions .idea/copyright/APACHE_2_0.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions .idea/gradle.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/misc.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/modules.xml

This file was deleted.

2 changes: 0 additions & 2 deletions .idea/modules/reactor-javafx.iml

This file was deleted.

2 changes: 0 additions & 2 deletions .idea/modules/reactor-javafx_main.iml

This file was deleted.

2 changes: 0 additions & 2 deletions .idea/modules/reactor-javafx_test.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

10 changes: 8 additions & 2 deletions README.md
Expand Up @@ -109,8 +109,14 @@ removed.
```java
fromChangesOf()
```
This factory is only provided for [ObservableArray](https://docs.oracle.com/javase/8/javafx/api/javafx/collections/ObservableArray.html)
and it emits the changed sub-array of the argument array whenever it has been changed.

Using this factory produces a `Flux` that emits a `Change` element as soon as any change (add/remove/modify) is performed on the underlying collection. If you want access to the actual underlying event from JavaFx collection, use this

The below factory method is provided for [ObservableArray](https://docs.oracle.com/javase/8/javafx/api/javafx/collections/ObservableArray.html) and it emits the changed sub-array of the argument array whenever it has been changed
```java
fromChangedSubArrayOf()
```


#### Collections
* [ObservableList](https://docs.oracle.com/javase/8/javafx/api/javafx/collections/ObservableList.html)
Expand Down
13 changes: 11 additions & 2 deletions build.gradle
@@ -1,5 +1,5 @@
group 'com.github.shadskii'
version '1.8.0'
version '2.0.0'

apply plugin: 'java'
apply plugin: 'jacoco'
Expand Down Expand Up @@ -65,6 +65,15 @@ modifyPom {
email 'jakehasssel@gmail.com'
}
}
contributors {
contributor {
id 'thekalinga'
name 'Ashok Koyi'
url 'https://thekalinga.in'
organization '1Ton technolgies'
organizationUrl 'https://1ton.in'
}
}
}
}
extraArchive {
Expand All @@ -76,4 +85,4 @@ nexus {
sign = true
repositoryUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
snapshotRepositoryUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
3 changes: 1 addition & 2 deletions settings.gradle
@@ -1,2 +1 @@
rootProject.name = 'reactor-javafx'

rootProject.name = 'reactorfx'
67 changes: 67 additions & 0 deletions src/main/java/freetimelabs/io/reactorfx/flux/ArrayChange.java
@@ -0,0 +1,67 @@
/*
* Copyright 2017 Jacob Hassel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package freetimelabs.io.reactorfx.flux;

import javafx.collections.ObservableArray;

/**
* This class represent a change emitted from a JavaFX {@link ObservableArray}
*
* @param <T> The type of object held by this ObservableArray
*/
public class ArrayChange<T extends ObservableArray<T>>
{
private final T observableArray;
private final boolean sizeChanged;
private final int from;
private final int to;

ArrayChange(T observableArray, boolean sizeChanged, int from, int to) {
this.observableArray = observableArray;
this.sizeChanged = sizeChanged;
this.from = from;
this.to = to;
}

/**
* @return underlying {@link ObservableArray}
*/
public T getObservableArray() {
return observableArray;
}

/**
* indicates if the size of array has changed
*/
public boolean isSizeChanged() {
return sizeChanged;
}

/**
* A beginning (inclusive) of an interval related to the change
*/
public int getFrom() {
return from;
}

/**
* An end (exclusive) of an interval related to the change.
*/
public int getTo() {
return to;
}
}
69 changes: 67 additions & 2 deletions src/main/java/freetimelabs/io/reactorfx/flux/FxFlux.java
Expand Up @@ -306,6 +306,19 @@ public static <T> Flux<T> fromRemovalsOf(ObservableList<T> source)
return ObservableListSource.removals(source);
}

/**
* Creates a {@link Flux} that listens for changes to the argument {@link ObservableList} and emits all of the
* changes to the list whenever it has been updated.
*
* @param <T> The type of the {@link ObservableList}.
* @param source The {@link ObservableList} to listen to.
* @return A {@link Flux} that emits the {@link ListChangeListener.Change}s to the list whenever it has been changed
*/
public static <T> Flux<ListChangeListener.Change<? extends T>> fromChangesOf(ObservableList<T> source)
{
return ObservableListSource.changes(source);
}

/**
* Creates a {@link Flux} that listens for changes to am {@link ObservableMap} and emits the argument {@link
* ObservableMap} whenever it has been updated. The initial {@link ObservableMap} will be emitted as the first
Expand Down Expand Up @@ -349,6 +362,20 @@ public static <T, V> Flux<Map.Entry<T, V>> fromRemovalsOf(ObservableMap<T, V> so
return ObservableMapSource.removals(source);
}

/**
* Creates a {@link Flux} that listens for changes to an {@link ObservableMap} and emits any changes to the
* argument {@link ObservableMap}.
*
* @param <T> The key type of the {@link ObservableMap}.
* @param <V> The value type of the {@link ObservableMap}.
* @param source The {@link ObservableMap} to listen to for removals.
* @return A {@link Flux} that emits the {@link ListChangeListener.Change}s to underlying {@link ObservableMap}.
*/
public static <T, V> Flux<MapChangeListener.Change<? extends T, ? extends V>> fromChangesOf(ObservableMap<T, V> source)
{
return ObservableMapSource.changes(source);
}

/**
* Creates a {@link Flux} that listens for changes to an {@link ObservableSet} and emits the set whenever there is a
* change to it. The initial {@link ObservableSet} will be emitted as the first emission of this {@link Flux}.
Expand Down Expand Up @@ -386,6 +413,19 @@ public static <T> Flux<T> fromRemovalsOf(ObservableSet<T> source)
return ObservableSetSource.removals(source);
}

/**
* Creates a {@link Flux} that listens for changes to the argument {@link ObservableSet} and emits all of the
* changes to the set whenever it has been updated.
*
* @param source The {@link ObservableSet} to listen to for removals.
* @param <T> Type contained by the {@link ObservableSet}
* @return A {@link Flux} that emits the {@link SetChangeListener.Change}s to the set whenever it has been changed
*/
public static <T> Flux<SetChangeListener.Change<? extends T>> fromChangesOf(ObservableSet<T> source)
{
return ObservableSetSource.changes(source);
}

/**
* Creates a Flux that listens for changes to a {@link ObservableIntegerArray} and emits the entire array whenever
* it has been changed. The initial {@link ObservableIntegerArray} will be emitted as the first emission of this
Expand Down Expand Up @@ -420,11 +460,23 @@ public static Flux<ObservableFloatArray> from(ObservableFloatArray source)
* @return A {@link Flux} that emits the changed sub-array of the argument {@link ObservableIntegerArray} whenever
* it has been updated.
*/
public static Flux<ObservableIntegerArray> fromChangesOf(ObservableIntegerArray source)
public static Flux<ObservableIntegerArray> fromChangedSubArrayOf(ObservableIntegerArray source)
{
return ObservableArraySource.observableIntegerSubArray(source);
}

/**
* Creates a Flux that listens for changes to a {@link ObservableIntegerArray} and emits the {@link ArrayChange} of
* the array whenever it has been changed.
*
* @param source - The ObservableIntegerArray to listen to for changes.
* @return A {@link Flux} that emits the changes to the underlying array whenever it has been updated.
*/
public static Flux<ArrayChange<ObservableIntegerArray>> fromChangesOf(ObservableIntegerArray source)
{
return ObservableArraySource.observableIntegerChanges(source);
}

/**
* Creates a Flux that listens for changes to a {@link ObservableFloatArray} and emits the changed sub-array of the
* array whenever it has been changed.
Expand All @@ -433,8 +485,21 @@ public static Flux<ObservableIntegerArray> fromChangesOf(ObservableIntegerArray
* @return A {@link Flux} that emits the changed sub-array of the argument {@link ObservableFloatArray} whenever it
* has been updated.
*/
public static Flux<ObservableFloatArray> fromChangesOf(ObservableFloatArray source)
public static Flux<ObservableFloatArray> fromChangedSubArrayOf(ObservableFloatArray source)
{
return ObservableArraySource.observableFloatSubArray(source);
}

/**
* Creates a Flux that listens for changes to a {@link ObservableFloatArray} and emits the {@link ArrayChange} of
* the array whenever it has been changed.
*
* @param source - The ObservableFloatArray to listen to for changes.
* @return A {@link Flux} that emits the changes to the underlying array whenever it has been updated.
*/
public static Flux<ArrayChange<ObservableFloatArray>> fromChangesOf(ObservableFloatArray source)
{
return ObservableArraySource.observableFloatChanges(source);
}

}

0 comments on commit 047d3d3

Please sign in to comment.