Skip to content

🚀: Create Reducer DSL with per-intent handling and config options #202

@Nek-12

Description

@Nek-12

Description

We could achieve a nice intent handler DSL by building a FlowMVI plugin to replace reduce with a more robust handler, and additionally, give users an easier way to split their reducers apart (even though that'd make it less safe).

Example:

reducer {
   on<CounterIntent.Increment> {
        distinct() // default equals, allow customizing, similar to compose remember
        filter { it.value > 2 }
        mode = Cancel // what happens when queue builds up
        handle {
           updateState { copy(counter = counter++) }
        } // consider requiring handler builder return type from this lambda
   }
}

Requirements:

  • Per-intent configuration available (e.g. drop latest on one, serialize on another intent)
    On new intent options:
  • drop new
  • cancel old
  • await
  • parallel
  • per-intent catch blocks (opt?)
  • filter/debounce/distinctUntilChanged for intents per-intent

Metadata

Metadata

Assignees

Labels

triageNeeds triaging

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions