feat: action debounce and throttle configuration#38
Conversation
…h throttle and debounce modifiers, updated ServerAction classes and their descendants to support the new options. Updated parsing methods and added corresponding lookup tables for execution modifiers.
WalkthroughThis change introduces execution throttling and debouncing support for server actions. A new Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant DuitDataSource
participant ServerAction
participant ExecutionOptions
Client->>DuitDataSource: Provide JSON input
DuitDataSource->>DuitDataSource: executionOptions()
DuitDataSource->>ExecutionOptions: Parse modifier & duration
DuitDataSource-->>ServerAction: Return ExecutionOptions
ServerAction->>ServerAction: Construct with executionOptions
ServerAction-->>Client: Action instance with options
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Possibly related PRs
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🧰 Additional context used🧠 Learnings (1)📚 Learning: in the duit_kernel framework, lookup table access in duitdatasource methods intentionally uses non-n...Applied to files:
🔇 Additional comments (5)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (5)
lib/src/action_api/action.dart(6 hunks)lib/src/action_api/execution_options.dart(1 hunks)lib/src/action_api/index.dart(1 hunks)lib/src/view_attributes/data_source.dart(1 hunks)lib/src/view_attributes/lookup.dart(1 hunks)
🔇 Additional comments (10)
lib/src/view_attributes/lookup.dart (1)
1417-1434: LGTM! Well-integrated lookup tables.The new
ExecutionModifierlookup tables are well-implemented and follow the established patterns in this file perfectly. The comprehensive string mapping (including both simple and fully-qualified names) and clear integer mapping provide flexible deserialization options.lib/src/action_api/index.dart (1)
9-9: LGTM! Proper API exposure.The export statement correctly exposes the new execution options functionality through the public API, following the established pattern in this index file.
lib/src/action_api/execution_options.dart (2)
1-40: Excellent enum design and documentation.The
ExecutionModifierenum is well-designed with clear behavioral distinctions:
- Throttle: Executes first call, ignores subsequent calls within duration
- Debounce: Delays execution until quiet period expires
The comprehensive documentation with practical examples makes the API easy to understand and use correctly.
80-100: Well-designed data class with comprehensive documentation.The
ExecutionOptionsclass is properly designed as a final data class with:
- Required parameters ensuring complete configuration
- Clear field documentation explaining their purposes
- Excellent class-level documentation with practical examples
The design enforces that both modifier and duration are always specified, preventing incomplete configurations.
lib/src/action_api/action.dart (4)
29-36: Clean integration into base class.The
executionOptionsfield is properly integrated into theServerActionbase class following established patterns. Making it nullable is appropriate since execution options are optional functionality.
62-76: Consistent integration pattern.The
LocalActionclass properly integrates execution options using:
- Super parameter for clean constructor delegation
- Consistent JSON parsing pattern using
DuitDataSourceThe implementation follows established conventions in the codebase.
103-121: Proper integration following established patterns.The
TransportActionchanges maintain consistency with other action types, using the same super parameter pattern and JSON parsing approach viaDuitDataSource.
133-150: Approve ScriptAction integrationThe
ScriptAction.fromJsonimplementation correctly delegates tosource.executionOptions(), and theexecutionOptionsmethod is defined inlib/src/view_attributes/data_source.dart, returning anExecutionOptions(ornull) based on the JSON input. This matches the pattern used by other action types and requires no further changes.lib/src/view_attributes/data_source.dart (2)
4026-4032: LGTM on the conversion method.The
_executionOptionsFromMapmethod correctly uses the existingduration()method and the_executionModifier()helper to construct an ExecutionOptions instance. The implementation is clean and follows the established patterns in the codebase.
4048-4064: LGTM on the main execution options method.The
executionOptionsmethod follows the established pattern used throughout the DuitDataSource class for parsing complex objects from JSON. It properly handles type checking, caching, and graceful fallback to default values.
- Refactor DuitDataSource methods with one-line return and fail-fast approach at lookup tables work
* breaking: DuitDataSource (#32) * experiment - removing attribute support * wip * wip * wip * refacror ViewAttributes class * Added tests * wip * Added early exit from methods * Added new functions for handling JSON parsing results, improved default result return logic, and added table mapping for BlendMode and FloatingActionButtonLocation. * docs * add tests * Added tests * Removed static mapping tables for Clip, TextAlign, TextOverflow and TextWidthBasis in the DuitDataSource class. * Added new methods for JSON processing, including support for textDecorationStyle, fontWeight, fontStyle and other attributes. Improved logic for returning default values and added corresponding tests. * Added tests * Removed unused methods and added new functions to handle theme rules and image filters. Updated tests to check new features and JSON processing logic. * Upd .gitignore * wip * Upd tests, added Tween parser * Removed ventilation methods, added new functions for widget handling. Updated tests to check new features and JSON handling logic. * Refactored functions for creating InputBorder and ShapeBorder from a map, as well as corresponding lookup tables. Simplified logic for selecting the border type. * Added docs * upd actions config * wip * wip * Update test/theme_test.dart Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * clean dead code * fix * Update lib/src/view_attributes/lookup.dart Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Added export of Command.dart file to action_api and removed it from animation_api. Updated data references in DuitDataSource class to use new "stretchModes" key. Fixes to tests to match changes in step data. --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Remote commands API update (#33) * breaking: Themes refactoring (#34) * Registry API update: Added new RefWithTarget class, changed component initialization and registration functions, removed unused files, and improved export structure. Updated tests and removed deprecated topic tokens. * upd workflow * breaking: Reworking the widget model API and simplifying registration of custom widgets (#35) * Removed unused factory_record.dart file and updated component registration logic in DuitRegistry class, removed references to model factories. Updated factory getter methods to match new changes. * Small fix for tweens parser * rm unused API part * Update lib/src/registry_api/registry.dart Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * review fixes * fix --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Improve lootup tables for enums (#36) * Flutter types json encoding (#37) * Added encoding functions for: Duration, Size, EdgeInsets, TextStyle, Color, LinearGradient, BoxShadow, Offset, BoxDecoration, BorderRadius, Border, BorderSide, InputBorder, InputDecoration, VisualDensity, ScrollPhysics, ShapeBorder * wip * Added tests * Apply suggestions from code review Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Fix tests * Added docs * dart format --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * feat: action debounce and throttle configuration (#38) * Added execution options for actions: added ExecutionOptions class with throttle and debounce modifiers, updated ServerAction classes and their descendants to support the new options. Updated parsing methods and added corresponding lookup tables for execution modifiers. * - Added test - Refactor DuitDataSource methods with one-line return and fail-fast approach at lookup tables work * fix Color parsers behavior * refactoring: improved color handling in _colorFromList function Changed the typification function of the _colorFromList parameter from List<num> to List, added preprocessing of color data to ensure correct conversion. Updated the corresponding calls in the JSON parsing and processing methods in the DuitDataSource class. * feat: Fragments registration in DuitRegistry (#39) Added a new static method registerFragment for registering fragments by key and a method getFragment for receiving a fragment by key with logging in case of absence. Also added an internal registry of fragments _fragmentRegistry. * Component system refactor (#40) * Components refactoring via JSON patching instead of Map mutation * Added tests for json patching and components patches generation * Review fixes * Upd lookup table for Curves * Remover legacy API references * feat: DuitDataSource methods extension (#41) * Extend parser for BorderRadius type, added Radius type parsing, upd tests * fix tests * Added new Size parsing behavior * wip * feat: Custom json reviver (#42) * Refactor env variables, refactor analysis issues in test files, added FlutterPropertyKeys class * wip * wip * wip * Fixed analysis issues * wip * Fixed getActionDependencies and childObjects methods * Upd env variables keys * Code review fixes * Fix test * Upd post-merge workflow
Summary by CodeRabbit
New Features
Documentation