domino-aggregator-shared

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

Лицензия

Лицензия

Группа

Группа

org.dominokit
Идентификатор

Идентификатор

domino-aggregator-shared
Последняя версия

Последняя версия

1.0.2
Дата

Дата

Тип

Тип

gwt-lib
Описание

Описание

domino-aggregator-shared
provides a declarative way to wait for a set of events to be completed before executing some code.
Ссылка на сайт

Ссылка на сайт

https://github.com/DominoKit/domino-aggregator
Организация-разработчик

Организация-разработчик

Dominokit

Скачать domino-aggregator-shared

Зависимости

test (2)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.13.1
org.assertj : assertj-core jar 3.7.0

Модули Проекта

Данный проект не имеет модулей.

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.

Версии библиотеки

Версия
1.0.2
1.0.1
1.0.0