Class DispatchStoreLayer


  • public class DispatchStoreLayer
    extends Object
    A DispatchStoreLayer allows to intercept any Dispatch instance and execute the appropriate StoreAction on a given Store. An instance of DispatchStoreLayer is specific to one shard, in case of sharded connection to the gateway, a separate DispatchStoreLayer should be created for each of them. It is completely independent to the gateway client itself, its use is completely optional.
    • Method Detail

      • store

        public Mono<StatefulDispatch<?,​?>> store​(discord4j.discordjson.json.gateway.Dispatch dispatch)
        Executes a store action depending on the type of the given dispatch. The dispatch given in argument is assumed to come from the same shard as given when creating this DispatchStoreLayer. The shard info will be overriden if an instance of ShardAwareDispatch is provided. The result of the store action, which represents the old state of the data affected when applicable, is returned along with the dispatch itself in a StatefulDispatch which can be processed downstream.
        Parameters:
        dispatch - the dispatch to produce the store action for
        Returns:
        a Mono where, upon successful completion, emits the StatefulDispatch holding the result of the store action execution, if any. If an error occurs during store execution, the error is dropped and logged, and a StatefulDispatch with empty old state is returned.