use of com.amplifyframework.hub.HubEventFilter in project amplify-android by aws-amplify.
the class HubAccumulator method create.
/**
* Creates a {@link HubAccumulator} that accumulates events arriving on a particular channel,
* whose event name is the given enum value (as string). For example, the accumulator
* created as below will match all events with name
* {@link DataStoreChannelEventName#OUTBOX_MUTATION_PROCESSED}:
*
* HubAccumulator.create(HubChannel.DATASTORE, DataStoreChannelEventName.PUBLISH_TO_CLOUD);
*
* @param channel Channel on which to listen for events
* @param enumeratedEventName A enum value, the toString() of which is expected as the name of
* a hub event. Only events with this name will be accumulated.
* @param quantity Number of events to accumulate
* @param <E> The type of enumeration
* @return A HubAccumulator
*/
@NonNull
public static <E extends Enum<E>> HubAccumulator create(@NonNull HubChannel channel, @NonNull E enumeratedEventName, int quantity) {
Objects.requireNonNull(channel);
Objects.requireNonNull(enumeratedEventName);
HubEventFilter filter = event -> enumeratedEventName.toString().equals(event.getName());
return new HubAccumulator(channel, filter, quantity);
}
Aggregations