domino-aggregator-shared

provides a declarative way to wait for a set of events to be completed before executing some code.

License

License

GroupId

GroupId

org.dominokit
ArtifactId

ArtifactId

domino-aggregator-shared
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

gwt-lib
Description

Description

domino-aggregator-shared
provides a declarative way to wait for a set of events to be completed before executing some code.
Project URL

Project URL

https://github.com/DominoKit/domino-aggregator
Project Organization

Project Organization

Dominokit

Download domino-aggregator-shared

Dependencies

test (2)

Group / Artifact Type Version
junit : junit jar 4.13.1
org.assertj : assertj-core jar 3.7.0

Project Modules

There are no modules declared in this project.

Development Build Status Maven Central Sonatype Nexus (Snapshots) GWT3/J2CL compatible

domino-aggregate

provides a declarative way to wait for a set of events to be completed before executing some code.

This might be implemented later using Rx or Futures.

Maven dependencies

  • Release

    • Api

      <dependency>
        <groupId>org.dominokit</groupId>
        <artifactId>domino-aggregator-shared</artifactId>
        <version>1.0.0</version>
      </dependency>
      
    • Annotation processor

      <dependency>
        <groupId>org.dominokit</groupId>
        <artifactId>domino-aggregator-apt</artifactId>
        <version>1.0.0</version>
        <scope>provided</scope>
      </dependency>
  • Development snapshot

    • Api

      <dependency>
        <groupId>org.dominokit</groupId>
        <artifactId>domino-aggregator-shared</artifactId>
        <version>HEAD-SNAPSHOT</version>
      </dependency>
      
    • Annotation processor

      <dependency>
        <groupId>org.dominokit</groupId>
        <artifactId>domino-aggregator-apt</artifactId>
        <version>HEAD-SNAPSHOT</version>
        <scope>provided</scope>
      </dependency>

Usage

  • Basic
ContextAggregator.ContextWait<String> waitForString = ContextAggregator.ContextWait.create();
ContextAggregator.ContextWait<Integer> waitForInteger = ContextAggregator.ContextWait.create();

ContextAggregator.waitFor(waitForString, waitForInteger)
        .onReady(() -> {
            //will be called when both waits are resolved.
        });

waitForString.complete("some string");
waitForInteger.complete(5);
  • Declarative

1 - iIn a class define a method and annotate it as @Aggregate specifying a desired class name, and the method parameters represent the events to be received.

public class App{
    @Aggregate(name = "EventsAggregate")
    public void onAllEventCompleted(String event1, Long event2){
        //will be called when both waits are resolved.
    }
}

2 - Define a field of the aggregate class, which should be generated for you

private EventsAggregate eventsAggregate = new EventsAggregate();

3 - Init the aggregate with an instance of the target class from which the method will be called.

eventsAggregate.init(appInstance);

4- Complete the events to invoke the target method

eventsAggregate.completeEvent1("some string");
eventsAggregate.completeEvent2(5);

Full sample

public class AggregateTest {

    private EventsAggregate eventsAggregate = new EventsAggregate();

    
    public void AggregateTest(){
        eventsAggregate.init(this);
    }

    @Aggregate(name = "EventsAggregate")
    public void onAllEventCompleted(String event1, Long event2){
        //this will be called when both events are completed.
    }

    //In some other parts you complete the events, something like in a success of failed rest call.
    public void shouldCallAggregateMethod(){
        eventsAggregate.completeEvent1("some String");
        eventsAggregate.completeEvent2(5L);
    }
}
org.dominokit

DominoKit

Service Providers, UI library, Modular framework and GWT experts.

Versions

Version
1.0.2
1.0.1
1.0.0