Skip to content

Latest commit

 

History

History
42 lines (32 loc) · 1.24 KB

customizing-the-dispatcher-and-failure-behavior.md

File metadata and controls

42 lines (32 loc) · 1.24 KB
icon
joystick

Customizing the dispatcher and failure behavior

Lamp's strategy for finding the best command is not fail-proof, and, because it relies on user input, it may not always be able to find the error cause spot on (simply put, it may not exist, or there may be many!)

Therefore, Lamp allows you to tweak the resolution strategy, and change the failure behavior. This is done using the DispatcherSettings class, which you can customize using Lamp.Builder#dispatcherSettings().

DispatcherSettings

The DispatcherSettings class allows you to customize the following:

  1. The maximum number of commands it should try
  2. The failure behavior that receives all the failed attempts (Potentials) and the user input. This is done using the FailureHandler interface.

Example

{% tabs %} {% tab title="Java" %}

var builder = ...;
builder.dispatcherSettings(settings -> {
    settings.maximumFailedAttempts(10).failureHandler((actor, failedAttempts, input) -> {
        ...
    });
});

{% endtab %}

{% tab title="Kotlin" %}

val builder = ...
builder.dispatcherSettings { settings ->
    settings.maximumFailedAttempts(10).failureHandler { actor, failedAttempts, input ->
    
    }
}

{% endtab %} {% endtabs %}