Is there a way I can merge property changes that I know will always happen together?

Hello

Is there a known or suggested way to react to changes in ownership that occur always at the same time?  I'll post an artificial example.  Here is roughly what I'm trying to accomplish.  I can't get the formatting on the forum to work right, so here's a link to pastebin:

http://pastebin.com/vK7PLKYh

The issue that I have with the above is that whenever I change "input" the predicate group updates once for each change and my list gets filtered twice.  I'm really not interested in the second amendment, but I don't know of a way to make sure that the predicate contained in my filter group stopped to change before allowing change to be propagated to my filtered list.  The essential is that the predicates changes in my air filters independent of each other in my group of filters, but they are in fact by the same event.

Here is an example as any son in roughly the same way as I do.

import javafx.beans.Observable;
import javafx.beans.binding.StringBinding;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

public class CoalesceEventsNeededExample {
 public static void main(String[] args) {
 new CoalesceEventsNeededExample();
 }

 private int computeCount = 0;

 public CoalesceEventsNeededExample() {
 final ObservableList<Item> items = FXCollections.observableArrayList(item ->
 new Observable[] {item.idName} // idName changes invalidate list
 );

 // other items bind to this and use it to calculate another value
 final Item source = new Item("0");

 final Item one = new Item("1");
 final Item two = new Item("2");

 // both items name values are bound to the source item's name value
 one.name.bind(source.name);
 two.name.bind(source.name);

 // both bound items are stored in the list. if the idName for either of
 // these changes, the list will be invalidated.
 items.addAll(one, two);

 // a concatenation of the idName of every item in the list
 StringBinding allIdNames = new StringBinding() {
 {
 bind(items);
 }
 @Override
 protected String computeValue() {
 computeCount++;
 StringBuilder sb = new StringBuilder("Names: ");

 for(Item item : items) {
 sb.append(item.idName.get()).append(",");
 }

 return sb.toString();
 }
 };

 // print observed changes to the console
 allIdNames.addListener((o, old, newValue) -> System.out.println("allIdNames changed: " + newValue));

 // the compute count will start as 1 - the initial compute of allNames
 System.out.println("computeCount is " + computeCount);

 // set the source name. the effect will be an update of the idName
 // property of both items in the list. the allNames value will get
 // re-computed for every idName change. since there are 2 items in the
 // list, this will cause allNames to be re-computed twice.
 //
 // the first value is uninteresting and i'm only interested in the
 // second (computed) value. is there any way to defer the computation
 // of allNames until all bound idName values have updated?
 source.name.set("blah");

 // compute count is now 3
 System.out.println("computeCount is " + computeCount);
 }

 private class Item {
 private final StringProperty name = new SimpleStringProperty();
 private final StringProperty idName = new SimpleStringProperty();

 private Item(final String id) {
 // idName is computed from id + name. when the source item changes
 // this value gets re-computed
 idName.bind(new StringBinding() {
 {
 bind(name);
 }
 @Override
 protected String computeValue() {
 return id + "-" + name.get();
 }
 });
 }
 }
}

Is it possible I can delay the invalidation / Re-calculation of (ex :) allIdNames so it only occurs after the idName has finished editing the colon?)

ReactFX has be inhibited by and colaescing links with this single reduction function, maybe they can help?

reduceSuccessions: accumulates events emitted in the close temporal succession into one.

combine: areas emits a combined each time value widths or heights emit a value, but only after the two widths and Heights had issued at least once.

pause: when you interrupt the flow, the events that would be normally issued are buffered and emitted when the stream is not suspended.

reduce: while it is intercepted, keep reducing (accumulation) the events together. The result of the reduction is emitted when the interception ends.

InhiBeans: InhiBeans are extensions of links and properties of javafx.beans.* which helps prevent redundant invalidations and recalculations.

When there is a network of linked values, it often happens that an single user on one end of the network action causes a succession of changes of value to the other end of the network. Most of the time, redundant events invalidation and change cause no problems, but they can come with a decrease in performance if Auditors attached eagerly perform expensive computations. InhiBeans help to inhibit this madness of invalidation.

Tags: Java

Similar Questions

Maybe you are looking for

  • weird things are happening

    I started getting this error message and now Google game store disappeared out of my phone its just disappeared. And no man, I'm not rooted. I am also unable to sync my Google account.

  • Compatibility with Office 2007 and Office 2003 Concerrns

    I have the Vista operating system and MS Office 2007 is installed on my computer. The version of MS Office 2007 I don't have Microsoft Publisher. However, I have the 2003 version of Microsoft office professional disk that does not have Microsoft Publ

  • Authentication for switches

    Hello I have ben using the AAA command sequence and get my TAC routersauthenticated Server SE 4.2.Now I need to get cisco 3560 and 6513 switches authenticated by the same ACS server, kindly suggest if modifications may be required in orders. AAA new-

  • No templates found when creating assets

    As an administrator, I have created a new model, definition of flex.As a contributor trying to create assets in Flex, it doesn't show any model. Gives a message "no templates found. Why do not the created model.

  • Enable trace in standard EBS PLSQL pkg and know the path of the trace file

    Hello I want to activate the trace in the standard package of PLSQL EBS: run immediately "alter session set sql_trace = TRUE"; How can I know the path of the trace file?What is the name of the table to know the path of the file trace? Thank youLavan